does anyone have good links or tips on best practices concerning migrating from ASP.NET Webforms to ASP.NET MVC?
We have a large webforms application that we would like to piece by piece migrate to MVC. Here is our current setup.
Two big Webforms project (VB)
Multiple class libraries and services (C# and VB.Net)
Subsonic 2.2 Data access layer
SQL Server 2008 DB
We are considering the following:
Keep the classic webforms project running as is for now while developing.
Create new MVC project based on MVC 3 with Razor view engine
Use Nhibernate (Repository pattern) DAL
Convert/build the existing functionality module by module in the MVC project
Replace some functionality in the old webforms project with new MVC modules if possible. Integrate via eg. Iframes.
In time the new MVC app will replace the old webforms project entirely.
We would like to keep the DB as is so we also need a tool to create the Model based on the DB.
Is this a possible solution?
WebForms applications use server-side session a lot because most of the server controls use it internally. You will not be able to use any of the server controls that you used in WebForms in MVC3 (atleast without some tinkering).
MVC3 promotes the use of restful architecture, where any state is maintained in html or url or cookies, and these are reasons why I think you should revisit the decision to convert to MVC3. Do so only if it will give you a huge advantage, because I suspect you will be reinventing ground up your existing app - I suspect there will be an equal amount of effort migrating it as to while developing it new.
Again there is nothing preventing you from creating an "area" or a "region" of MVC in your webforms app, if your goal is to use MVC for future development.
If you still want to move to MVC3, take a look here
It is ok solution. Also for NHibernate you can use MyGeneration with NH plugin to generate models on top of existing DB. And it is also possible to host WebForms and MVC together in one web app. Just finished quite the same task. But used EF for DAL.
What's the best way to structure the base functionality of an ASP.NET MVC 3 solution so it can be reused in subsequent solutions? For example, I'm going to develop a basic skeleton MVC app with user registration using email verification, enhanced users/right/roles, blogging with comments, and a forum. I understand maintaining the business logic in class libraries but how about the controllers and views? Do I basically have to just copy and paste my base solution to create each of my new solutions?
Creating a Custom ASP.NET MVC Project Template
templify
I am going to start new MVC 3.0 .NET 4.0 application.
I want to implement each component for my web site once and simply reuse it then for another web sites i going to build.
Currently i am looking the best practice i can use to achieve my goal.
I did some research and found that I may get a lot of advantages using MEF.
I found interesting MEF MVC solution called plugable MVC http://www.thegecko.org/index.php/2010/06/pluggable-mvc-2-0-using-mef-and-strongly-typed-views.
Is it really worth to use such kind of approach(Plugabble MVC) of building MVC apps?
Advantages disadvantages of pluggable MVC?
May be somebody may suggest something else?
What specific problem are you trying to solve? MVC is a very extensible and pluggable framework as it is. I would say that for a simple site MEF is not necessary. Please provide more information on the issues you are running into with the stock MVC framework.
Two of the biggest advantages of MVC over webforms were non-existent viewstate and URL routing. VS2010 and .NET 4.0 incorporates built-in URL routing for Webforms as well as better control for viewstate.
I advocate use of MVC for extranet sites due to the MVC design pattern and its general lightweight nature but in light of this new announcement has Webforms closed the gap? Why would you still pick MVC over Webforms?
Thanks
You're forgetting about 2 main advantages of MVC: better control over generated HTML and better support for test-driven development.
I'd say that normally implementing a site using ASP.NET WebForms would require less effort that implementing exactly the same with MVC.
MVC gives you more control, but it also requires more expertise and effort.
I know that an MVC framework allows you to separate business logic, data base access and presentation, but why do we need a framework to do this.
Can't we just keep our classes separated, perhaps using different packages/folders for the model, view and controller classes?
In my opinion the thing you are talking about is the MVC pattern and not a specific framework. Of course you can go and keep all your classes within one project and still use the MVC pattern, as you have all your UI code in the views, the logic in the controllers, ...
A MVC framework on the other hand makes it easier for you to use this pattern. It may provide some base classes for controllers and a mechanism for the communication between view and controller.
I don't know if you are familiar with ASP.NET MVC. The framework itself is very small, but it helps you developing an application with the MVC pattern, as you don't have do think about the previously decribed areas...
Hope this helps
An MVC framework is a framework written to split up the the business logic, database access and presentation.
This is very useful in most web applications, and now lately into software/desktop applications.
This is due to the fact that following the MVC model, your code will be much clearer, cleaner and you keep your application DRY (Do not Repeat Yourself).
You can write your own classes and separate them into Model, View and Control. But again, you will need a framework to help you in accomplishing certain tasks. Like a List control in ASP.NET, or PHP framework being able to help you translate text between languages and so on. (Oh why reinvent the wheel?!)
MVC and framework is a different thing. MVC is just an architectural pattern, which can be applied with any project, with or without framework.
So you don't need a framework to do this. You can separate them by yourself. :)
MVC stands for “MODEL” “VIEW” “CONTROLLER”. ASP.NET MVC is an architecture to develop ASP.NET web applications in a different manner than the traditional ASP.NET web development. Web applications developed with ASP.NET MVC are even more SEO (Search Engine) friendly.
Developing ASP.NET MVC application requires Microsoft .NET Framework 3.5 or higher.
Model:
MVC model is basically a C# or VB.NET class.
A model is accessible by both controller and view.
A model can be used to
pass data from Controller to view.
A view can use model to display
data in page.
View:
View is an ASPX page without having a code behind file.
All page specific HTML generation and formatting can be done inside view.
One can use Inline code (server tags ) to develop dynamic pages.
A request to view (ASPX page) can be made only from a controller’s action method
Controller:
Controller is basically a C# or VB.NET class which inherits system.mvc.controller.
Controller is a heart of the entire MVC architecture.
Inside Controller’s class action methods can be implemented which are responsible for responding to browser OR calling views.
Controller can access and use model class to pass data to views
Controller uses ViewData to pass any data to view.
MVC is a code organization architecture style to organize your code-logic in a meaningful way for web applications. As a programmer I have almost puked when I have inherited other people's code when their code logic is all over the place and following their web application code turns into following a rabbit down the gutter hole. Why MVC? hmm.. well why should I use a filing cabinet or folders to organize my plethora of paper and not just have my papers stashed in a large pile and have others figure how they connect to each other. It increases code readability. With MVC it becomes very easy to follow code logic since you are following standard structure for a web application. Business logic is separated out from UI. Easier to delegate work decouple work on a project.
You can of course approach it yourself by segregating your classes. A framework supplies common scaffolding that you wouldn't have to build yourself. But it will also impose some structure on your code. You'll have to evaluate whether the framework helps more than it hurts.
You are correct, there are strategies that you can implement to help with separation of concerns without using MVC.
Microsoft's ASP.NET MVC framework is one strategy that can be employed, and that is what I think you are asking about.
This MVC framework makes such separation of concerns easy.
The other major advantage of MVC is testability - (depends on whether you believe in unit testing - I do).
The MVC framework ensures that all orchestration logic is on your controllers and through the FormControls collection allows full unit testing of all aspects of your application except for how it is presented.
As the MS MVC framework encourages adherence to common rules and structure of the application which should lead to greater maintainability.
The major downside of MVC is the code-in-front code weaving required for presentation, but this can be easily overcome.
Perhaps this is just a linguistic thing. I've seen "frameworks" referring to themselves as a DSL -- Domain Specific Language.
And you don't need a framework But here's something to consider: You already know for a web app you're going to want to do a few common things... route URLs, render pages, etc. Why re-write it all? For other problem domains you'll have generic things to do as well.
Hai Friends There are somemany types of architecture frame work has been there,firstly i know 2tier and 3 tier frame work ,the 3 tier and mvc ,entity framework are same but in different name's,so study a good background in any one architecture there fore if you went to any multinational companies ,you can easly score/highlight to your carrer.
Model View Controller or MVC as it is popularly called, is a software design
pattern for developing web applications. A Model View Controller pattern is made
up of the following three parts:
**Model** - The lowest level of the pattern which is responsible for maintaining data.
**View** - This is responsible for displaying all or a portion of the data to the user.
**Controller** - Software Code that controls the interactions between the Model and View