From classic asp.net to asp.net with MVC
What thought process changes around application design would you recommend to someone completely new to asp.net with MVC who has typically worked on classic asp.net projects, in terms of new ways MVC expects you to think about your design?
Aside fr开发者_运维百科om the conventional separation of concerns bit where each layer has it own responsibility, there are new ways of working which one needs to be aware of. For eg. in MVC 3 we have the razor engine where you cant use any server controls. There is no postback. The page lifecycle looks different. etc.
More specifically, what are the things one will need to unlearn or re-learn in order to make the shift from classic asp.net to asp.net MVC with webforms or razor.
Thanks for time and sharing your views...
Edit
Has anything changed with respect to sessions, caching? Also, I am trying to understand routing. It seems to be required to be done for every view there is in my mvc webforms application along with the parameters. Wont this mean that I have to consider many different permutations there? In razor there seems to be no such need to map request routes. So under what conditions do I go for Razor over webforms in MVC applications?
where you can't use any server controls
errr!, they are now called Helper Controls, and their are cousin of web form controls, for example:
in WebForms Engine:
<asp:GridView ID="gv" AutoGenerateColumns="true" runat="server" CssClass="tbl-grid">
<AlternatingRowStyle CssClass="row-alt" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
Food: <asp:TextBox ID="txt" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
in MVC Engine:
var grid = new WebGrid(@Model, canPage: true);
@grid.GetHtml(
tableStyle: "tbl-grid",
alternateRowStyle: "row-alt",
columns: grid.Columns(
grid.Column("Title","Movie",
@<text><input type="text" id="txt_@item.Title" /></text>), ...
So you do have a lot of Helpers to play around, and it's super easier once you pass the division of concerns that MVC represents, plus, you start to have full control of what you write in each view, use PartialViews
etc ..
It will be hard in the first tries, but keep searching StackOverflow for your questions and I'm sure tha they are already answered here, plus:
Microsoft also partnered with Pluralsight and they are giving you a fantastic MVC (And Webforms) for ASP.NET 4.0 essential tutorial completely for free, just go through all video tutorials, I own a PLuralSight monthly account and they are really good in what they do:
MVC 3 Essential Videos
http://www.asp.net/mvc
Webforms Essential Videos
http://www.asp.net/web-forms
Before you jump on your way to the MVC3 world, go through all Videos and you will know at the end, that there is nothing you can't do anymore :)
A while ago I wrote a series of blog posts on converting a classic asp site to MVC, the series is still not finished (I'm not the most prolific of bloggers!) and doesn't deal specifically with MVC 3 but the posts might be of some help. Here's a link -
http://www.notgoingdark.com/2011/04/converting-classic-asp-site-to-aspnet.html
精彩评论