Co-exist of ASP.NET MVC and Web form

Last post 01-18-2008 10:52 AM by Omnius. 2 replies.

Sort Posts:

  • Co-exist of ASP.NET MVC and Web form

    01-13-2008, 5:07 PM
    • Member
      2 point Member
    • mave99a
    • Member since 12-19-2007, 11:28 AM
    • Posts 8

    MVC makes a web application's architect quite clear, however in my point of view, MVC is not a great for all solution.

    One of MVC's pain points is handling the form submission. For a simple form submission, generally you need 2 action: ActionShowForm and ActionUpdateForm, the first action show a web form interface to let user edit the form, the second action is for submission. If you use server side form validation, it will be a little bit more complicated (depends on how you display those validation information to users).

    Traditional ASP.Net web form can handle above form submission in very simple and straight forward way, with just one .aspx file and one code behind .cs file, complex web form handling is a easy and enjoyable work. It's also very easy and without too much code to use ASP.NET ajax's update panel to get fancy update free ajax form effect.

    MVC frameworks has been used in Java web developing for a long time, look at what's Java's new movement?   It's JSF(Java Server Face), something really like ASP.NET, it also have something similar to "view state" and "post back". What a interesting thing it is:  after so many years working with MVC, Java guys are looking to web form alike "new" technology,  and after using web forms for so many years, ASP guys are so exciting about MVC. :)

    In one of my experiment project, I used ASP.NET MVC together with the web form.  MVC is used as the major part of the web site, Web forms are used for all those form handling, they co-exist pretty well.

    I create a folder named "forms", and put all web forms files (aspx and cs) inside this folder. Though it's ok to put them inside the "view" folder, I separated them because they are different  in modeling. The web forms share the same "Model" part (if it require to access the "model"), I use session data object to pass data in/out the  web forms.


     

  • Re: Co-exist of ASP.NET MVC and Web form

    01-14-2008, 4:51 AM
    • Member
      318 point Member
    • dimi3
    • Member since 12-13-2007, 5:02 PM
    • Posts 166

    Your point of view is interesting.

    Thank you for sharing your experience.

    Since the perfect technology doesn't exist, I think it's quite interesting to mix these 2 technologies.

  • Re: Co-exist of ASP.NET MVC and Web form

    01-18-2008, 10:52 AM
    • Member
      2 point Member
    • Omnius
    • Member since 06-26-2007, 11:05 AM
    • Posts 1

     I am trying to accomplish this in a project that has been under development for a while but isn't finished yet. I plan to convert it entirely to MVC eventually, but obviously I can't just snap my fingers and make it happen, so I wanted to start adding any new functionality through MVC but keep the rest of the already implemented features as is for now. Later as time permits I'll move features over from WebForms to MVC.

    I however cannot find any information on how to actually set that up. In part 2 of ScottGu's posts he mentions that the RouteHandler property on Route is the key "to make sure that the URL routing system can be used for both MVC and non-MVC requests". However, there was no explanation further than that. MvcRouteHandler implements IRouteHandler, but I can not find any other implementation of IRouteHandler at all.

    Can someone point me in the right direction on how to hook up a route to handle some legacy WebForms pages (they will all be under a single subdirectory)? 

Page 1 of 1 (3 items)