views:

350

answers:

2

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

+1  A: 

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);
        }
Nebakanezer
+1  A: 

Though the solution by Nebakanerer works for the root of the site, it didn't work for any urls that suggested sub-folders.

So instead I didn't for the Default.aspx file option but mapped all wildcards in IIS6 based website to aspnet_isapi.dll. Basically making ASP.NET handle all requests regardless.

This blog post explains the process: [http://weblogs.asp.net/scottgu/archive/2007/03/04/tip-trick-integrating-asp-net-security-with-classic-asp-and-non-asp-net-urls.aspx][1]

Gavin