MarimerLLC / cslaforum

Discussion forum for CSLA .NET
https://cslanet.com
Other
31 stars 6 forks source link

Any Samples for ASP.NET Core MVC? #526

Open mtavares628 opened 6 years ago

mtavares628 commented 6 years ago

Hi,

I've been using CSLA for a long time supporting an ASP.NET Webforms application for many years. An opportunity has come up for a new project and I'd like to continue using CSLA within an ASP.NET Core MVC application, but I can't seem to find a sample project or documentation on getting it up and running. I noticed that Rocky just closed an issue today regarding creation of ProjectTracker in MVC 6 (https://github.com/MarimerLLC/csla/issues/506). Does that mean a sample is forthcoming, or the issue has been abandoned? I have the Using CSLA 4 MVC ebook, but I suspect that it may be a little outdated for ASP.NET Core. Any guidance of where to start would be greatly appreciated.

Thanks.

rockfordlhotka commented 6 years ago

I was indeed cleaning up issues in the backlog today. I closed that MVC issue because I expect to work on an ASP.NET Core sample instead, given that Microsoft is putting all their energy into that platform these days.

Just haven't gotten around to adding the new issue for that purpose yet.

That said, my plan has been to use the Razor template as the start point, not the MVC template. Both are very valid of course - hard to say which one is the best to choose - but I don't have time to write the sample app in both models.

mtavares628 commented 6 years ago

Thanks for the response, Rocky. Working on an ASP.NET Core sample instead sounds great. In the meantime, do you have any recommendations of what I can look at to familiarize myself with CSLA with ASP.NET Core? And do you have an idea of when a sample may be available (no pressure of course 😄) ?

rockfordlhotka commented 6 years ago

"No pressure" - I love it! 😈

Really the basic concepts are no different from MVC 4. The way you create and bind views and controllers is largely the same, and the changes don't impact CSLA.

The big thing (starting with MVC 5) is that authentication is quite different, and there are various options. CSLA doesn't really care about that either, except that you need to ensure that HttpContext.Current.User and/or Csla.ApplicationContext.User end up with the current principal on each server request.

rockfordlhotka commented 6 years ago

fwiw, I spent some time this past week starting to learn the new Razor Pages model, and I really like it a lot! Much simpler than having to manually create controllers for each view.

rockfordlhotka commented 6 years ago

If you are using Razor Pages, please consider using the upcoming 4.7.200 release (#593), as I could use any testing or feedback on the new CslaModelBinder implementation.

ajj7060 commented 6 years ago

Heh, I was looking at https://docs.microsoft.com/en-us/aspnet/core/razor-pages/?view=aspnetcore-2.1&tabs=visual-studio and it seems like they just mashed the Model & Controller together into one class.

rockfordlhotka commented 6 years ago

That's true, but in so doing they changed the page lifecycle, data binding, and some other stuff. I personally think it is much simpler and eliminates a bunch of fairly redundant controller code. But there's certainly a learning curve!

ajj7060 commented 6 years ago

Haha, yes, I had no idea about this PageModel/Razor pages until I saw it in this thread, so that was my quick impression after spending 10 minutes reading that link. :-) I'll have to check it out sometime.