Asp – Hosting asp.net mvc on IIS6

asp.net-mvchosting

i changed my global.asax to register routes like this:
Public Class MvcApplication

    Inherits System.Web.HttpApplication 

    Shared Sub RegisterRoutes(ByVal routes As RouteCollection)

        routes.IgnoreRoute("{resource}.axd/{*pathInfo}") 

        ' MapRoute takes the following parameters, in order:

        ' (1) Route name

        ' (2) URL with parameters

        ' (3) Parameter defaults

        routes.MapRoute( _

            "Default", _

            "{controller}.aspx/{action}/{id}", _

            New With {.controller = "Home", .action = "Index", .id = ""} _

        ) 

        routes.MapRoute( _

            "Root", _

            "", _

            New With {.controller = "Home", .action = "Index", .id = ""} _

        ) 

    End Sub 

    Sub Application_Start()

        RegisterRoutes(RouteTable.Routes)

    End Sub

End Class

every thing works fine but the root path (www.mysite.com) does not work and i get an error like: "The website declined to show this webpage HTTP 403 "

how can i get rid of that??

Best Answer

If you add a Default.aspx page with the following Page_Load code, it will work:

        public void Page_Load(object sender, System.EventArgs e)
        {
            // Change the current path so that the Routing handler can correctly interpret
            // the request, then restore the original path so that the OutputCache module
            // can correctly process the response (if caching is enabled).

            string originalPath = Request.Path;
            HttpContext.Current.RewritePath(Request.ApplicationPath, false);
            IHttpHandler httpHandler = new MvcHttpHandler();
            httpHandler.ProcessRequest(HttpContext.Current);
            HttpContext.Current.RewritePath(originalPath, false);
        }