Alex Rivera | Logout

Adding MVC to a ASP.NET Website

Asked 2011-08-25T17:22:35.033
12

I'd like to add MVC support to an existing Website project (not a Web application project) and have a few questions.

  1. To get Visual Studio's MVC goodness, it appears that I need to update the .csproj file's <ProjectTypeGuids> node. There is no csproj file in a website project.
  2. It appears that I need to create Models and Controllers folder in the App_Code. Is this true? I prefer having these folders under root.
  3. For Views should I be creating a aspx and aspx.cs files? Is cshtml razor files supported in this kind of a setup?

Any other responses are appreciated. Thanks

Edit
Report

1 Answer

0

I have seen this work in the past if you place a Global.asax file in the root of your website. You'll need a way for your project to recognize and differentiate MVC requests from standard requests, like this:

public static void RegisterRoutes(RouteCollection routes)
{
    routes.MapRoute("Default",
        "{controller}.mvc/{action}/{id}",
        new { controller = "Home", action = "Index", id = "" }
    );
}

So, an MVC url in your app might look like: http://www.mywebsite.com/mycontroller.mvc/View/5

answered 2011-08-30T13:32:51.597

Your Answer