-
Sep 28th, 2020, 08:29 AM
#1
MVC Core Lessons
I've been doing a lot of development with ASP.NET (C#) as our back-end framework, but everything that I've done has been in .NET (not .NET Core) and I'm working off of a base stack where the nitty-gritty stuff to get the application stood up is already in place.
I'm wanting learn how to get an ASP.NET Core application stood up from scratch, but I'm having a bit of a difficult time doing so.
I followed MSDN's documentation (here) but a lot of the stuff like scaffolding the identity schema using Entity Framework code-first scaffolding sort of gets glossed over.
I've looked at Exam 70-486: Developing ASP.NET MVC Web Applications, but I can't tell if this is .NET framework or .NET Core and it is also set to expire at the end of January.
Do y'all have suggestions on any free or commercial websites that y'all really like?
-
Sep 28th, 2020, 10:27 AM
#2
Re: MVC Core Lessons
Subscribing/following because at some point, I'd like to figure this out too.
I've looked at Exam 70-486: Developing ASP.NET MVC Web Applications, but I can't tell if this is .NET framework or .NET Core and it is also set to expire at the end of January.
My guess is if it is expiring that early, it's not for .NET Core.
-tg
-
Sep 28th, 2020, 12:10 PM
#3
Re: MVC Core Lessons
I don't know why this is in Chit-Chat. I think General Developer would be better, but I'll be following along, as well.
My usual boring signature: Nothing
-
Sep 28th, 2020, 01:35 PM
#4
Re: MVC Core Lessons
I honestly thought it'd get more traction in chit-chat, but I went ahead and moved it to general developer forum.
-
Sep 29th, 2020, 04:47 AM
#5
Re: MVC Core Lessons
Dont know any specific resources, but i use .NET Core pretty much exclusively now for apps at work.
happy to help and post some code if you want, which areas are you having trouble with?
Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you
-
Sep 29th, 2020, 08:16 AM
#6
Re: MVC Core Lessons
Mainly getting it stood up.
I created a blank project, setup the DBContext, use the EF scaffolder to build the identity tables, and stubbed out a simple controller to do basic CRUD operations with the idea that for now I'd run Postman or Insomnia to hit the controllers until I built out my UI.
Right out the gate I'm having issues with IIS not wanting to run as well as issues with the dependency injection that my service layer is reliant upon.
-
Oct 1st, 2020, 03:57 AM
#7
Re: MVC Core Lessons
ah ok so when you say IIS not wanting to run do you mean when you deploy or just debugging ?
Here is a fairly simple example with just a single service injected and consumed by a controller with a single Get method, also i added in the AutoMapper setup
Dependency injection in .Net Core is not that different i tend to do by creating a seperate static IoC class.
Code:
public static class IoC
{
public static void Initialise(IServiceCollection services)
{
services.AddTransient<ICaseService, CaseService>();
}
}
and then calling that class on Startup at the end of configure services
Code:
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton(AutoMapperConfig.CreateMapperConfig());
services.AddDistributedMemoryCache();
services.AddSession();
services.AddControllersWithViews()
IoC.Initialise(services);
}
then a controller would look something like
Code:
public class CaseController : BaseController
{
private readonly IMapper _mapper;
private readonly ICaseService _caseService;
public CaseController(ICaseService caseService, IMapper mapper)
{
_caseService = caseService;
_mapper = mapper;
}
[HttpGet]
public async Task<IActionResult> GetMyCases()
{
try
{
var result = await _caseService.MyCases(UserPrincipal.User.LoginID).ConfigureAwait(false);
var model = _mapper.Map<CaseViewListVm>(result.Data);
return PartialView("~/Views/CaseView/_CaseView.cshtml", model);
}
catch (Exception ex)
{
throw;
}
}
}
here the automapper config class i am injecting
Code:
public static class AutoMapperConfig
{
public static IMapper CreateMapperConfig()
{
var mappingConfig = new MapperConfiguration(mc =>
{
mc.AddProfile(new AutoMapperMapping());
});
IMapper mapper = mappingConfig.CreateMapper();
return mapper;
}
}
Code:
public class AutoMapperMapping : Profile
{
public AutoMapperMapping()
{
CreateMap<CaseViewListVm, CaseViewListDto>();
CreateMap<CaseViewListDto, CaseViewListVm>();
}
}
Last edited by NeedSomeAnswers; Oct 2nd, 2020 at 03:38 AM.
Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you
-
Oct 6th, 2020, 03:53 AM
#8
Re: MVC Core Lessons
Hi DDay,
did the code i posted make sense in terms of your project? let me know.
happy to talk it over or provide some more code samples.
Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|