I’ve always coded in C# MVC3 when developing web applications. But now i wanted to learn a bit more about developing web sites with just ASP.NET.
But now i’m wondering what a good setup for my code would be. For me, an MVC like pattern seems to be a good way to go. But obviously ASP.NET doesn’t have any router
and controller
classes. So i guess people have a different way of setting up their code when they do ASP.NET.
So i’m looking for more information on how to get started with this. So not really the basics of ASP.NET, but something that focuses on a good code setup.
Any good tutorials/information about this/?
1
If what you’re referring to is ASP.Net Web Forms, best practices are somewhat of an opinionated and difficult to find topic (given that its conventions are very one-sided). However in your case I would highly recommend getting familiar with what’s new in ASP.Net 4.5 for web forms first. Features like Model Binding will help you cross-over into familiar territory. If you have used aspx views in any of your MVC projects you’ll have a great head start too. For web forms design in general, many of the older conventions on best practices still hold true from days past. There are some more unconventional approaches to web forms that may be worth a look. Web forms MVP is one and also the Spring Framework for .Net has a very nice adaptation that makes excellent use of Spring’s features to improve the web forms model greatly.
All in all web forms is good to know but IMHO you should stick with MVC and shoot for learning MVC4 and the new Web Api.
MVC3 is ASP.NET in every sense. It seems like you are referring to WebForms, which is the old platform for creating websites in ASP.NET. But I think you’ll find MVC to be a much better platform.
As mention by Alex, MVC offers a better separation of concerns by following the Model-View-Controller pattern, which can be implemented in WebForms, but has native support in MVC. It also offers better HTML code generation using the Razor engine, which I find pretty smart in most cases and very clean, simple code. Better file structure, and other features to keep the development on the actual site rather than handling requests back and forth IMHO.
7
You can get very MVC-like in current versions of webforms; features such as routing and model binding have found ways into that part of the framework.
In general, the right way to do .NET apps on any platform is to build a core library that is UI agnostic and tie the UI layer in. If you do it right you can deal with anything — be it WebForms, MVC, WPF or a console app — without significant pain.