This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
MVC versus WebForms
Almost all asp.net mvc vs webforms post I see on SO the selected answer always say ASP.NET mvc is more maintanable but do not give any reasons why. Do you know why MVC is more maintainable then webforms?
A lot of the argument for ASP.NET MVC being more maintainable than WebForms has to do with the following:
It cleanly maps to how web requests actually work, instead of shoehorning an eventing model onto the web.
There are more extensibility points to provide flexibility in solving problems.
The MVC pattern in general just tends to be more maintainable than a number of things due to the separation of concerns.
This is not to say however that WebForms cannot be written to be maintainable. There are definitely cleanly written WebForms applications out there, just as there are many cleanly written ASP.NET MVC applications.
Of course, you can make web form application maintainable by, for example, using MVP pattern. But most programmers doesn't do that because putting logics all over webform is quick and easy choice. After that programmer got fired or quits, next programmer should follow all the logics to fix a bug in the system. But that creates another bug because test can't be implemented. If the system is complex enough, any change almost guarantees a bug.
MVC doesn't give you that choice for easy path to hell. But this design pattern stuff of ASP.NET MVC is just small part of the story. You can google for the whole story.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am trying to build a large application using ASP.NET MVC and entity frameworks. I know this project will become very large at some point so I want to make sure I design it in a way to be able to manage it without lots of unnecessary work specially when I have more programmers helping me down the road.
Another thing I like to consider is the application deployment. I don't want to have to keep compiling my application every time I make update or add new section to my application.
I believe using the MVC design will keep my code clean and easier to maintain. But one thing I really want to enforce is a module design to keep my files organized.
Based on some searching I have done, three things came up Areas, MEF and MAF which seems to be based off the same idea.
I also learned that MAF may be an over kill for most projects where MEF is more in the lines of what I may be looking for.
Most of the articles that I found are at least 2 years old and talks about ASP.NET MVC 4. I am not sure how relevant that is to ASP.NET MVC 5 or ASP.NET MVC 6.
What is confusing to me is that MEF is a framework and ASP.NET MVC is another framework. Is it possible to use the two frameworks to get an MVC design with module base application that allows me to organize my file and not to have to compile my application every time I need to make an update or add a new module?
Is the combination of MVC and MEF consider a good start for a large application? Is there a better idea that I should consider when designing my application?
I don't think MEF is the answer to what you're looking for. MEF was designed with the idea of giving to the developers the ability to create a "pluggable" architecture.
Imagine to develop an app whose core will be shared among different clients, but with some custom modules for some of them. Then MEF is what you're looking for.
Instead, from what you're saying, I think you're just trying to create a tidy and solid architecture, easy to maintain in the future. You don't need MEF for that.
Here is a good article about how to structure big MVC applications keeping in mind the principle of separation of concerns: https://chsakell.com/2015/02/15/asp-net-mvc-solution-architecture-best-practices/
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I want to build websites in a modular fashion, so I can get better code reuse and abstract away some implementation details. I'm looking for advice on how to code such a website with ASP.NET and Visual Studio, and modules for such a website, because at the moment my websites don't have this nice property.
At the moment I'm working on a web-app that's providing a pretty straight-forward internally facing contact manager for a company. We plan on using identical contact managers (pointing to different databases) for each of our independent customer-facing websites (each for one of the company's businesses). I'm using ASP.NET MVC in C# with EntityFramework. What I'd like, is to be able to simply drop this contact manager package/project/class-library into a Visual Studio solution for an ASP.NET MVC Website, and then just add whatever 'wiring' I need to get them working together. I've seen the use of "areas" within MVC apps, that basically function as mini MVC applications, but it's been messy and actually less maintainable because of configs and different areas wanting different versions of assemblies (this is not code I wrote, and I want to avoid writing code like this). I have an idea of what this would look like in terms of data-objects and box&line diagrams; unfortunately, I don't know what this looks like in terms of views, controllers, projects, or assemblies.
The thing is, as a relatively unseasoned programmer, I've never done this before, so need advice on how to proceed. I'm unfamiliar with the patterns/idioms I need to implement this. So while I have the theoretical knowledge of how to write nice modular software architectures, I don't know they end up looking like in-terms of their actual classes, namespaces, and Visual Studio Projects/Solutions.
My question is, how do I build a website that's more modular than your standard MVC? And, if you have experience doing this (or attempting to), could you please share it? Or even better, can you offer a concrete example of such an architecture? (note this will probably require a link to something not on stack overflow, since you can't copy and paste an entire code-base to stackoverflow).
Apologies for not having a specific question, but this is a bit more complicated than a simple query of "how to traverse a b-tree", "why isn't my code compiling", "does anyone have a regex to do the thing I want", "I wrote some terrible code and now it broke", and "I haven't read the documentation (assuming there is any) and now I'm getting an exception that I don't understand". There likely isn't a single answer, because programming is complicated, solving real-world problems takes thought, and writing good code can be hard. Also, I can't exactly post the code I'm working with because of this thing in my contract known as a confidentiality clause, and not that anyone would read through 100's of thousands of lines of code and tell me how to make it better. \end_rant
I think you are looking for the "Onion Architecture".
Here's a live implementation of the Onion Architecture over on GitHub that uses Web API, MVC etc. It uses the all familiar Northwind database. So you can browse through the code and solution after you learn about this architecture and make sense of it and incorporate the parts you need in your project / solution.
Also, here's a nice tutorial on how to develop using this approach.
Finally, a Channel 9 Video that was what I originally found a few years back when I was researching the same thing, and found it very useful.
ASP.NET MVC Solution Best Practices
This video also takes an existing monolithic project and turns it into an Onion Architecture implementation, along with reasoning on why we are doing what at every step.
First of all you have to direct yourself in implementing your systems based on an approach that can provide complex systems that will not make everyone furious in waiting.
This is commonly known as the Domain-Driven design.
Then comes SOLID. SOLID represents architectural choices that will make your system easy to maintain and extend.
See SOLID in action using C#
All these along with Patterns of Enterprise Application Architecture can keep you busy for all your career and yet it could not be enough.
trying to follow the above in your programming will give you eventually a "less-monolithic" system and modular.
In ASP.NET MVC terms the above could mean:
Keep the MVC paradigm. Do not feed your controllers more than they should eat. Keep them only for what they are. Traffic cops. Also do not put logic in your views in order to keep them abstracted.
Maintain your logic in a separate "space". By the word "space" i mean a separate project, solution, assembly....whatever you think fits to your application size that you are building.
Use MVC Areas for what they are supposed to be. They fit perfectly for the FrontEnd / Admin case. You want to have a frontend that looks and operates differently from the backend, but obeys some general system rules.
Use Web API to make your application open and expendable. This will bring Javascript into play which itself needs to be addressed regarding SOLID e.t.c..
Do not overdose your application with javascript frameworks just for the shake of it. Use what you really need.
Use IoC container like Ninject to manage your dependencies..Marry your interfaces and let IoC resolve your implementations
If you going deep in javascript , take your time to define your viewmodels correctly. They are the contracts between 2 different worlds so they must be clear.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I've read plenty of questions and articles stating that converting from ASP.NET Webforms to MVC is near enough impossible. However I think my scenario is different.
I foolishly started working a project about a year ago in Webforms, but the approach I took (as far as I understand) is very MVC like. I have disabled forms validation, don't use any postbacks, use URL re-writing and all page changes are AJAX requests that load the page contents of ContentPlaceHolders (using a small hack, overriding the RenderControl method). I've also used my own ORM and RESTful Service API in seperate projects, referenced in the website.
Now the system works really well, the pages are partially refreshed fine and the url's are changed when the ajax calls are made, so when the page is refreshed, it looks exactly the same.
Now I've just been told I need to learn MVC for a new big project (but I have to finish another project first), but I've done a bit of reading on the subject and started a few Hello World apps, and it seems that the idea of ASP.NET MVC is pretty much exactly what I have already created.
Would StackOverflow still recommend against converting the Webforms application to MVC? Are there any other benefits of converting to MVC, besides best practices?
I have a very large and old ASP.NET WebForms application (which was originally written for .NET 1.1!) and have enabled MVC to work in it, side-by-side. I've been writing new features using MVC, and converting old WebForms features to MVC controllers and views.
I ran into a few little issues concerning URL authorization and running in IIS integrated mode, but once I understood the issues they were fairly easy to work out. So nearly impossible? Certainly not!
I can't tell you if it's worth your time to convert it, since I don't know the size, scope or nature of your application, or any business constraints. However, moving to MVC has been a considerable boon to ease of development and quality (since it is easier to compartmentalize and unit test). Not to mention, the features I've written (or rewritten) in MVC are much cleaner, faster, and responsive than the WebForms equivalents.
I'm excited to move it from MVC v2 to v3, and convert to Razor views. So would I? I if I were you and I had the time, I'd do it.
Here's a question I posted that outlines the process and one of the more significant problems I had in the conversion. Migrating legacy ASP.NET to MVC 2 (RC): HttpApplication events not firing, User principal is null
I've recently converted a medium size project from WebForms to MVC. I would not recommend doing that on your first MVC project, but once you get the hang of it there really is nothing stopping you from (gradually) converting a WebForms app to MVC.
One of the major benefits I've noticed is speed. By throwing out the viewstate, databinding and web control weirdness you'll end up with a much faster application.
Of course there's also the better known benefits like testability and full control over the generated html.
WebForms and MVC share the same basic ASP.NET platform, so they are really not as incompatible as you've read.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I want to ask experienced ASP.NET developers about how to climb the learning curve of ASP.NET.
I am an experienced C++ and C# developers with no web application experience.
I found ASP.NET MVC and ASP.NET are two different technologies. I just want to ask:
Whether these two technologies will co-exists or MVC will replace
ASP.NET?
If I want to learn ASP.NET MVC. Do I need to learn ASP.NET as a prerequisite?
Can you recommend some learning resources? Book? Video? Not paid Microsoft training :(
Many thanks
First of all ASP.NET is request/response pipeline. This means that you are given access to the request and response streams as well as some provisions like, session, cache, security, etc.
On top of this there are 3 frameworks in charge for generating HTML. The first and oldest is known as ASP.NET Web Forms. Because it was the only one it is sometimes called ASP.NET but this is not correct in the current state of things. ASP.NET MVC is the second one and there is a third one known as ASP.NET Web Pages. All 3 of these share the same core ASP.NET request/response pipeline and the APIs for Session, Cache... What is different is how they generate HTML.
You can check my answer to this question for more info.
Asp.Net Web Forms and Asp.Net Web Pages
And to answer your concrete question - no Web Forms is not going away. A lot of people use it, MS are releasing new versions.
Web Forms is pretty good for people with desktop background because it uses a control model familiar to desktop devs and also has something that simulates state. It also requires less knowledge of HTML, JS, CSS. ASP.NET MVC is kind of the opposite. It gives you a lot of control but requires a lot of knowledge about the web.
I personally prefer Web Forms to MVC for a variety of reasons that I will not list here but even Web Forms supporters (and especially me) will admit that Web Forms is pretty bad way to learn about the web because it abstracts a lot of things. This gives you productivity, security, etc. but can result in cases of leaky abstraction if you don't know how the underlying framework works and it is pretty easy to skip learning the details because you know stuff just works... until it breaks and then you don't know where to start.
Ultimately the choice is yours but if you start with Web Forms be sure to learn about HTTP verbs, cookies, raw response stream, http headers, html form/submit model inline css vs separate files and javascript out of the context of Web Forms and make sure you know how Web Forms automates these.
1) Whether these two technologies will co-exists or MVC will replace ASP.NET?
The official position of Microsoft today is that those two technologies will coexist. ASP.NET MVC will not replace classic ASP.NET. At least Microsoft will continue shipping new features in ASP.NET.
2) If I want to learn ASP.NET MVC. Do I need to learn ASP.NET as a prerequisite?
Not necessarily but it will be better if you learned it because as ASP.NET MVC is based on ASP.NET kernel and it will help you be a better understand the underlying technology.
3) Can you recommend some learning resources? Book? Video? Not paid Microsoft training :(
http://asp.net/mvc is a good start.
Can't say if one is going to rule the other one out.
But the easiest to learn is asp.net MVC.
Pro ASP.NET MVC 3 Framework
this is a good book to learn it.
http://www.w3schools.com/aspnet/default.asp
http://aspauthors.com/aspnetbyexample/
http://www.exforsys.com/tutorials/asp.net.html
Some links which may useful to you.
Darin gives you good answers on 1 and 3, but i disagree some on 2:
2) If I want to learn ASP.NET MVC. Do I need to learn ASP.NET as a prerequisite?
No. ASP.NET WebForms (often reffered to as just ASP.NET) has a VERY different paradigm.
While ASP.NET WebForms tries it best to hide all the web (like POST vs. GET, the HTML, how to maintain state) stuff from you, ASP.NET MVC is dependant on knowing and understanding the same things. Learning aboutWebForms' ServerControls and ViewState are of little help.
There are of course parts of the ASP.NET stack that you'll encounter in both WebForms and MVC. The different state mechanisms (session, application, cookies etc.), the Server, Reguest and Response objects, caching mechanisms, jQuery etc. are used in both places.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
There's a lot to C# & ASP.net. Where should I start? What should I not bother focusing on?
Should I learn Winforms then WPF? Ditto for webforms / Silverlight?
Should I learn ASP.MVC or classic ASP.NET? If both, which first?
In the either/or cases - which will make more sense having known the other first?
What major .NET feature(s) should I learn upfront that will open the doors of understanding to what lies ahead?
I am deliberately not mentioning fundamentals like value / reference Types, Classes, object-oriented concepts, etc since they should come first, before specifics. Here, I am interested in specifics.
[edit - added detail of what my goals are]
Good points raised - "what do I want to write"?
Basically, an intranet application that monitors a set of documents and implements a workflow as a change control process. The app will also audit the documents and report problems, self-correcting common errors. A lot of the parameters will need to be end-user definable and pluggable. The document format needs to be adaptable to different proprietary formats although they are fundamentally the same. The app will be very modular.
I'm leaning towards a web interface because the client specs & admin rights will vary - a browser is really the only thing I can count on.
As you can see, it's a bit of everything.
What do you want to write? If you want to write a Windows client-side app, look into WinForms and WPF (no real need to learn WinForms before WPF, other than the way that a lot of tutorials/books will probably compare WPF concepts with WinForms concepts). If you're looking at a web app, then ASP.NET or ASP.MVC - I don't know whether you really need the "normal" ASP.NET before MVC.
Silverlight is a bit of both, in a way - rich client probably talking to a server for interesting data etc.
Before learning any of these though, I suggest you learn the fundamentals which are one step up from the topics you mentioned - things like how text works in .NET (including encodings and regular expressions), I/O, perhaps threading. Oh, and LINQ :) There are a few books which are very good on this front:
C# 3.0 in a Nutshell
CLR via C#
Accelerated C# 2008
I had the same question when I moved from Classic ASP to .NET 2.0... .NET is huge: so where should I start?
What i did was put my hand dirty and started slow, take a project (in my case was a very important project - a finance web app that would cover and automatize all 4 persons work) and start to implement, every time I didn't know how to accomplish something or I had an idea in ASP but not in ASP.NET I would go to www.asp.net or 4GuysFromRolla website and search for examples, copy/paste, understand what I was doing and ... continue to the next wall.
Took me 6 month to have everything up and running but was worst it! now that passed almost 3 years I know I did the right choice but back then ... I was scared!
now... you refer .NET 3.5, it has a bunch of new things like extensions, linq, etc... I would go by the simple part and when the times comes, "maybe I can use LINQ here, let me search how to use it on this part"
hope you follow your own path and buy some reference book so you can read something new and have a reference whenever you need "ahhh, I read this somewhere in the book, let me search... where was it?"
I bought Professional ASP.NET from Wrox as a reference book, and even today I go there to see new things, even when I'm started to use .NET 3.5, the idea is there, there is only a new way to accomplishing it.
I would recommend learning whatever you are interested in. Pick a "pet project" and try to create it using one of the technologies you listed. If you enjoy making windows desktop style applications, then go with WPF or WinForms. If you enjoy the idea of making rich desktop style applications on the web, then go for Silverlight. There will be a ton of overlap.
But in terms of core .NET Development, if I were starting off fresh, I'd recommend learning ASP.NET MVC first, as it will give you a good basis for things like: Designing for Testability, coding without ViewState, SEO-friendly URLs, etc..
It depends (awful response, I know, but let me explain)
Are you going to do any windows forms development? You mention C# and ASP.NET, so to me it sounds like you are doing Web-based programming. If so, skip Winforms and WPF for now.
Silverlight is worth checking out, but it is still fairly new so I'd make it a 2nd priority.
Now to the MVC or Web forms question. MVC gives you total control over the HTML, CSS, and Javascript that is emitted, but requires more work, whereas Web forms gives you ease of development but without 100% control over the markup that is emitted. You can do lots with Web forms and the introduction of MVC doesn't threaten the future of Web forms. MVC is very new so things are changing but eventually I see them both living happily side by side.
Regarding learning .NET in general, I've heard great things about a book called CLR via C# which will go over all the fundamentals and inner workings of .NET.
Definitely learn the fundamentals (like you already mentioned) like how the CLR handles types, garbage collections, security, "AppDomains", threading, etc.
For ASP.NET, learning the "page life cycle" and "control life cycle" are essential. Also, session state and data binding are probably good things to understand.
I wouldn't worry about WinForms, WPF, or Silverlight for now. They won't directly help with ASP.NET and are relatively easy to pickup after you've learned the CLR and .NET Framework fundamentals.
What is your primary objective - learning for fun or hireability? If you're a student and years out from worrying about a career in programming then I will strongly echo the idea of picking a project about something relatively simple that you're interested in and then just doing it.
Say you want to create an application that will track your video games collection. First you'll need a way to store the information - this will be a combination of c# and some persistence strategy like mySql or SQL Server or XML.
Then you'll need a way to present your collection and interact with it - adding, deleting and editing objects and persisting the changes. In this step, use every presentation technology that you're interested in - WPF, WinForms, Asp.net, asp.net with MVC, Silverlight - whatever you're interested in. As you learn to do one, you'll learn techniques you'll need to use in the next.
Don't pick just one - play with all the ones you have any interest with at all.
Now, if you're primarily interested in what skills will get you hired the quickest, I'd say look at your market, but it's probably going to be straight ASP.Net skills that will be the most in demand - or at least that's what it looks like from my perspective. In a couple of years it may well be ASP.Net MVC skills. In some markets though you'll have an easier chance of getting VB6 work. It all depends on where and when you're looking.
I highly recommend the following books, for learning about whats new in ASP.NET 3.5
ASP.NET MVC 1.0 Website Programming
Professional ASP.NET MVC 1.0
ASP.NET 3.5 Website Programming
Sometimes videos might help. I learnt everything I needed to know to start off with from a set of video tutorials from Total Training which is here. Pricey if you buy the disks but there is a cheaper online only option.