Asp.Net MVC Areas, how can I use them? - asp.net

I've got two questions about Asp.Net MVC areas. I have only a shallow understanding of areas from what I've heard about them in various podcasts but I think I understand fairly well what they're supposed to be used for. Now my question is if I could also use them to enable me to gradually switch from development in Asp.Net webforms with VB to Asp.Net MVC with C#.
Can I mix areas of different languages in one application, for example one area is a C# project and another is a VB.Net project.
Could I use the areas feature to incorporate MVC into an existing webforms application? Lets say I have a Asp.Net webforms application but I want any new "pages" to be written using MVC, could I create a new MVC project and then "jack it in" as an area into the existing webforms application?

In response to your questions:
Yes. If it's a separate assembly, then it won't matter if it's in c# or VB.net.
I'd say yes - it will help to keep your MVC stuff separate, but of course you will need the basic bootstrap stuff in your base webforms project. Good idea.
I've recently started introducing MVC into an older webforms site, and it's well worth the effort.

Related

Confusion on using asp.net or mvc

Ive been confused about ASP.NET MVC.
As some said, MVC is better than ASP.NET. As some said, they are completely the same thing.
And my colleges debate that MVC is just an extension of asp.net, where asp.net is already in the form of MVC.
In fact I am starting web developing from scratch. If someone might help to clear the fog front of me, it would help a lot.
All ASP.NET web frameworks are build on top of Microsoft ASP.NET Framework. The unique feature of Web API is that it can be used with both MVC and WebForms applications to provide truly restful HTTP services.
Regarding the choice of suitable Asp.NET framework: you may get more information from official source - www.asp.net.
General rule of thumb is the architectural design how you want to build your application.
ASP.NET MVC promotes a cleaner separation which makes the developer think more in depth about design and code separation than traditional web forms.
There are endless debates about what is better but true benefits of ASP.NET MVC as
testability
more control over the rendered HTML
separation of concerns. However with MVC there is much more to learn for the developer.
ASP.NET WebForms - will always be around because some see it as a rapid application development tool. Just drag and drop and let ASP.NET handle the posting, state etc
ASP.NET Web API - is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.
All in all, each of them has certain business solutions to be considered as required.
References to look for comparison:
ASP.NET MVC vs WebForms: speed and architecture comparison
ASP.NET Roadmap: One ASP.NET – Web Forms, MVC, Web API, and more
ASP.NET is the name of the overall web framework. There are a few different technologies that are built on ASP.NET. Two popular examples of these technologies are WebForms and MVC.
WebForms promotes a programming model that looks a lot more like Windows Forms. It attempts to abstract away the stateless nature of the web, and encourages you to use server-side controls instead of HTML. Because WebForms was the primary way to write web applications on ASP.NET for a long time before MVC came out, you'll often see people talk about "ASP.NET" as the same thing as WebForms. This is part of the reason for your confusion. ASP.NET WebForms is very different from ASP.NET MVC, but they are both built on ASP.NET.
ASP.NET MVC gets away from server-side controls. It eliminates the abstractions, allowing you to have closer control over the actual HTML that gets generated. For developers of modern applications, this is very useful because it makes it much easier to use AJAX and rich client-side javascript.
(Humble Opinion incoming)
ASP.NET (in terms of using Webforms) is programming the web for a WinForms developer. You "bind" events, you have "controls" and everything (sessionstate) is stored in a huge hidden field within the page so it knows where it left off from the previous call. You rely heavily on this information being present which is why everything you do needs to reside in that master form wrapping the entire page.
On the other hand, MVC is bringing C# .NET programming back to the web the way the web was intended. No bloat, no hidden fields, no heavy bindings. It's brings everything back to the classic "i have this form and now I need to process it". Arguably, the real magic is the routing methods and the "automatic binding" of submitted fields to an object. (if fields x, y & z are submitted and your action is looking for FooBar with the properties x, y & z it's automatically converted for you.
ASP.NET is common to both WEB-API and ASP.NET MVC. I assume you wonder about MVC or WEB-API.
MVC is a controller / model based with Views. Although the controllers can be used for AJAX json purposes. MVC is a good way to build a serious Browser based Application. The WEB-API allows you to build simple http server features, not necessarily Browser related. Good for REST style programming. Very flexible and a good alternative to WCF services. The are good tutorials on Both on the official ASP.NET site. START here http://www.asp.net/get-started
choose depends on your project n you. I suggest you to choose MVC because its productivity is very high we r using it since 1 year and found better than webforms.
for more knowledge please visit http://www.asp.net/mvc
The choice depends completely on you, I have been developing MVC application since 2010, its going to be over 2 years now have worked with almost all the versions of MVC both with Razor and aspx view. I have also worked on ASP.Net webform based applications.
With MVC you will not get built in controls, you will have to develop every control you want to use, you will have to rely mostly on html controls, while with web forms you will get advantage of using built in controls, Even getting help from other developers in your surroundings may be easy for webforms as you can easily get a webform developer.
But on the other hand with MVC the maintability is very high. As for as productivity is concerned, its very high once your are accustomed to it, initially it will be low as you will be in learning phase. Don't forget to use Entity Framework.
You may also consider developing your App using WebAPI, if it suits your scenario.

mix-up WebForm and MVC in one project vs separate them in 2 projects in the same solution

I've tried to mix up WebForm and MVC in the same application, but so far I've failed miserably. It looks like I'm missing some steps some how some where. I'm really tired.
I wonder if just it's bad prectice to have 3 projects in a solution: The first one for the Model, the second one for the Webform, and the last one for the MVC.
Thanks for helping
If you have two separate projects one for MVC and one for classic WebForms it's like you have two distinct web applications. Those two should be deployed separately in different virtual folders in IIS.
On the other hand you have the possibility to mix classic WebForms and ASP.NET MVC in the same project.
Usually people have some legacy WebForms application that they want to migrate in ASP.NET MVC. But due to the sheer amount of code this cannot be done at once so you would create a new ASP.NET MVC application and import the existing legacy WebForms inside it which could be directly used. Then you could progressively update legacy code to the MVC pattern.
But from personal experience I find it dirty mixing classic WebForms with ASP.NET MVC. My hands just feel dirty. What I do is that I would keep legacy WebForms as a separate application and start replacing different sections of it with a new ASP.NET MVC application and the two of them would communicate only through standard HTTP techniques (usually GET and POST verbs).

Asp.net MVC VS ASP.net WebForms?

I am starting a new project in VB /.Net Framework 2.0 for a company corporate website with data driven forms. So should I go further with Asp.net MVC or Asp.Net web forms and WHY ??? We are not ready for Ajax now but later.
And also we have DevExpress components.
Actually I see ASP.NET MVC as next generation in that it is an evolution - trying to be a better programming environment, as software development for web apps asks for something more testable.
It is a huge beast. Decide based on features whether you need it. MVC has less documentation and is a lot harder to master thanks to a less RAD approach, but it seems that once you are in, it will be quite a better experience. If you have a web application (like stackoverflow.com) then it may be a good approach.
DevExpress components - have fun... throwing them away. Like most ASP.NET components they will not work or only work very partially. Totally different approach.e
ASP.Net MVC is not "next generation" ASP.Net. It's an alternative approach to design that can be more beneficial depending on the kind of project you're working with. Without more information about the particular type of project you're working on no one can give you any informed recommendations.

Does asp.net MVC depends on Normal asp.net

this is my first question Here ,
I am a beginner in asp.net , and i want to make a CMS project using it
After Some readings I found that the MVC structure is very suitable for Me
Just want to know :
how much the asp.net MVC depend on the normal asp.net??
as a beginner i don't know the level of knowledge for Normal asp.net to start working using asp.net MVC
Please tell me where to start in the normal asp.net(3.5) and when to switch to learn the asp.net MVC ??
Detailed information is very welcome
Thanks For your Time
It is built on normal ASP.NET minus postbacks, viewstate, and event wiring. The underlying System.Web stuff is the same, but with some new wrappers to access it, and of course a bunch of new featuers that make up the MVC portion. Just get a book on ASP.NET MVC, and don't worry about classic ASP.NET.
'normal' (also known as WebForms) asp.net and 'mvc' asp.net are somewhat different from each other in how things are put together and how things work with each other. There is no need to learn one before learning the other.
If you read through this article you can see at a glance what the differences are between 'normal' or WebForms and 'mvc'.
Here is a pretty good tutorial for learning about MVC from Scott Guthrie if this is the way that you're leaning.
Good luck and have fun!
It depends on what you mean by "ASP.NET". ASP.NET MVC does depend on standard ASP.NET request processing pipeline (IHttpModules, IHttpHandlers and all other internal workings), but it does not depend on WebForms infrastructure.
I've recently jumped on the ASP.NET MVC bandwagon and I found the introduction tutorials on the official http://asp.net/mvc site very useful.
ASP.NET WebForms tried to mimic WinForms desktop apps in that you have controls and event-driven interaction, which is not particularly well suited to the stateless HTTP
ASP.NET MVC gives you full control over the HTML that is generated and sent back to the browser, but more importantly, it makes it easier to write testable code.
Also, ASP.NET MVC does not depend on ASP.NET WebForms, they are built on the same foundation. In fact, in principle, you can mix and use both in the same app if you really wanted to :)
When MVC was released, what used to be simply ASP.NET was renamed ASP.NET Webforms and MVC because ASP.NET MVC. Not sure if that answers your question but it does clear up some terminology.
Why not start with Asp.Net MVC ?
Asp.Net is split now into 2 parts. Webforms and MVC.
I'd advise looking at the following -
http://bloggingabout.net/blogs/mischa/archive/2008/02/04/asp-net-mvc-vs-asp-net-webforms-vs-ruby-on-rails.aspx
http://nerddinner.codeplex.com/

Ideas to improve/enrich a WebForms application by adding ASP.NET MVC elements to it

I'm currently present with the following situation.
We have a huge enterprise application written with WebForms. Refactoring it or completely rewriting it is out of the question. So I'm not talking about migration WebForms -> MVC.
However, I understand one can technically add MVC functionality to coexist with the rest of the project. I was asked to present MVC concepts for a team so that we can consider how it could become (or not) of use to us.
After careful thinking I do not see any ways or reasons to add MVC elements to a WebForms project since it will become a strange breed then.
Maybe there are certain not exactly obvious possibilities to add value to a WebForms project with MVC framework? Has anybody thought about it?
Sharing a master between MVC and WebForms - dealing with the
Mixing ASP.NET Webforms and ASP.NET MVC
ASP.NET MVC WebForms Hybrid application
Combining MVC and WebForms from Pro ASP.NET MVC Framework (also available here)
I would also look at this article from Scott Hanselman. He seems to have the mojo on mixing these technologies.
Plug in Hybrids...Mixing ASP.NET and ...

Resources