Migrating a webfrom asp.net appllication to MVC - asp.net-mvc

I have been working on a CMS project based on asp.net webforms. It follows simple multitier architecture and contains a single aspx page where the usercontrols (ascx) in the form of modules are loaded dynamically.
Now a lot of clients are demanding it in MVC. I m wondering if it is feasible to seamlessly convert it into MVC. Is the hype just because MVC is the new paradigm for dot not or is it because it does yield substantial benefits?
What is the easiest way to migrate from WebForms to MVC?

You can always convert your existing ASP.NET web application project to include MVC and make it as a hybrid application. Scott Hanselman wrote a simple post to demonstrate how to do that.
If you are trying to add MVC to existing ASP.NET web application, Check out this link. I have scribbled a useful tip there to bring the MVC specific Context menu ( Add Controller/Add View) in the solution explorer.
The below statement is purely personal. (of course both has it's own pros and cons)
Personally If i start a new project, i will choose MVC over webforms. because i tasted it. It is addictive. :) I think My MVC projects are much cleaner than webforms ones.

Related

Using ASP.NET MVC under ASP.NET Web form project - Best practice

Currently we have a new menu item to our existing asp.net web forms application.
We have decided to go with MVC for this.
Please note that we have to share the same masterpages, css and Jquery files. We are currently planning to render the view inside a div in our aspx pages.
Is there a better way to accomplish this?
What are the limitations of our approach?
Can we leverage the MVC test cases in this approach?
Thanks
MVC is a stateless, disconnected architecture, you can not access the master page or aspx controls directly in the controller as aspx.cs does, secondly it is not possible to use the classic asp.net master page with mvc.
The things you can re use from existing project are:
UI Templates (design)
JS files
CSS files
Business Logic
Database
You can't use same master pages. You can't reuse ASP.NET MVC for some parts of your webforms view and vice versa. Either your view is completely on webforms or on ASP.NET MVC. And theoretically even mix of webforms with mvc in one web application could be problematic, but practically possible (see below point 1). So generally answer to your question is no.
If you are looking to ASP.NET MVC, you should think about step-by-step migration of your project to it.
Actually there are a couple of possibilities how to migrate
Mix in one project ASP.NET web forms and ASP.NET MVC. Technically it is possible. But it is some kind of hack. Your transition will be seamless but you can't your ASP.NET views. I will not recommend it. You can find this approach here http://www.devcurry.com/2013/05/adopting-aspnet-mvc-enhancements-in.html
In one solution use different projects for your webforms and mvc projects. In fact these are 2 different web application which typically could have common authentication, and there is question with webforms state. To solve problem with authentication you need create separate web service for it, which will be used by both. To solve problems with session state, use distributed caching for both, and try to change thinking from webforms state to caching, because mvc is actually stateless. Then for particular views you can redirect between views of both portals

Relation of webforms in MVC

I am a beginner to MVC technology and have few questions.
1) How can I webforms in MVC and why/when should I used it ?
2) If we can build a application using razor view engine then why webform engine is provided ? If it is, we can continue to use traditional web forms.
3) Can I combine razor/aspx view engine in one project.
Coz I can see we can add WebForm/master pages by right clicking in View folder ....
Any help on this appreciated.
Well I'll recommend you reading some ASP.NET MVC book instead. Because it will give you basic understanding of MVC concept. But still:
You can't use webforms in MVC. Because it's completely different approach;
MVC gives you more flexibility over markup, you can customize your application easily. Again read about MVC pattern. Webforms instead are faster to develop, but heavier in terms of size and have some ugly things like viewstate;
Yes, you can. But in different pages, not in the same page.

Incorporating MVC functionality in an existing ASP.net project

We have an intranet system developed using asp.net webforms. We are kind of planning to partly incorporate mvc and such a scenario is as follows,
We would like to generate html documents using mvc (using razor view engine) where the inputs are going to come from a normal asp.net webform (from a form button click or so)
Some pointers or references to tutorials on running these 2 scenarios side by side would help a lot.
ASP.Net MVC and WebForms postbacks don't mix; the only way to do this would be to use <iframe>s (which is not a good idea).
I am not sure about your described implementation... however, you could start by re-writing some of your aspx pages using MVC views and just get all the existing code behind into a controller to minimize the creation of new code. You could do this one page at a time until all of your pages are MVC views. Good luck.

Have anybody compared ASP.NET MVC to CodeIgniter?

Is there a lot of similarities? I can webforms ASP.NET and some CodeIgniter but haven't much grokked with the asp.net mvc. Have they a lot of similarities?
Other than being frameworks build around MVC there aren't many similarities. (ie they both have folders for Models/Controllers/Views and automatically wire things for you based on naming conventions)
CodeIgniter is the most basic implementation of MVC possible, which allows for incredible flexibility when building your app.
ASP.NET MVC has alot built into it, and is strongly typed. LINQ to SQL provides a built in ORM and the basic MVC templates have frameworks for authentication built in utilizing ASP.NET Membership provider model.
Views in MVC are typed as well, so you have to define the model being passed into the view as opposed to CI which you can pass anything basically.
The helper classes are completely different as well.
ASP.MVC is built upon ASP.NET so alot of things will seem similar with Webforms, but you need to understand MVC pattern. Check out the NerdDinner tutorial for a fantastic introduction to ASP.MVC. (which is a Wrox book which they now make available for free online)
http://www.asp.net/mvc/learn/

ASP.NET MVC & Expression XAML - How do I integrate?

Some Background:
ASP.net MVC is primarly a paradigm shift in the way you structure and develop ASP.NET applications. Shifting from a "code behind" type of mentality to more of a standard MVC Ruby on Rails like mentality. I applaud it's efforts as a simlifying tool towards unit testing ease and seperation of code (although the html inline code could be debatable).
Expression and XAML is a way to describe the presentation layer that can be simple for designers.
The question is:
If we are to use ASP.NET MVC in developing our next website how does the design team that uses Expression and XAML supposed to create (V)iews or integrate into the development flow?
More specifically can Expression users still operate in an ASP.NET MVC world?
Note that the pages in Expression's model use a code behind paradigm as well.
It is a hack, but you can use XAML to render static images in ASP.NET MVC. Check out my post XAML Meets ASP.NET MVC - Serverside Image Rendering - that shows how to render XAML and WPF controls as an image in ASP.NET MVC
http://amazedsaint.blogspot.com/2010/07/xaml-meets-aspnet-mvc-create-databound.html
There is also the MvcXaml project that is a View Engine that allows for images to be dynamically generated based on a XAML view.
http://mvcxaml.codeplex.com
I will try to answer this, making several assumptions that may be wrong.
ASP.Net MVC is a web technology and XAML is a desktop one. You can use XAML inside Internet Explorer, but it's basically a hack, it works best for desktop or silverlight applications.
If you want a paradigm similar to MVC for the desktop, you should try the M-V-VM pattern, who is more appropriate to WPF and XAML.
With M-V-VM you can create views almost code-behind free.
A great intro to M-V-VM is this video by Jason Dolinger
If you are making a website using MVC and you are trying to integrate the design team, you should let them create the HTML+CSS views of your site, while the developers create the controllers and the models.
Please comment in this answer if I have misinterpreted the question.
I'm currently banging my head on these terms. However, maybe this silverlight-as-a-view-in-aspnet-mvc article will help? You've asked about XAML, and I thing this is what Silverlight uses...

Resources