2

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 from 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?

4
  • the best tip i can think of is 'walk before you can run'. learn how to do basic stuff with controllers and keep your views simple - i tried diving into MVC and putting JSON everywhere without really understanding how any of it worked - and did myself no favours Commented Sep 9, 2011 at 8:50
  • slightly off topic here, but do you get to use the asp.net ajax framework in an mvc app or is it jquery all the way? Commented Sep 9, 2011 at 9:01
  • AFAIK you can't use the web forms ajax framework. i use jquery and there are plenty of ways to use ajax: haacked.com/archive/2008/07/29/… mikehadlow.blogspot.com/2008/10/… Commented Sep 9, 2011 at 9:14
  • @user20358 re Ajax framework: If you are going to take the plunge, I would recommend go with jQuery, in the long run it would lead you to be more HTTP-friendly (i.e. stateless) and follow more normal/regular web practices. Commented Sep 9, 2011 at 12:34

2 Answers 2

6

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="[email protected]" /></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 :)

Sign up to request clarification or add additional context in comments.

4 Comments

thanks. Is there any mapping currently available that says asp:GridView is now WebGrid... something similar to the rest of the controls?
whithout the Grid, what do you need more? everything is better manually! a <asp:listbox> it's just a <select> with a for each in the options, and you can do your own stuff to use as well.
Just like Datagrid gets rechristened to WebGrid in the MVC world what do the other server controls like repeater, listbox, dropdown, checkbox etc be called by?
a repeater is just a @foreach(), same as listbox and dropdown, but you can always use @Html.DropDownList() just search your self what you want to use, and see the videos as they show some of them
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.