Asp.net mvc hosting on IIS6

i modified my global.asax to register routes as follows: 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

everything works fine, but the root path (www.mysite.com) does not work, and I get an error, for example: "The website refused to show this HTTP 403 webpage"

how can i get rid of this?

+3
source share
2 answers

If you add the 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);
        }
+3
source

Although the Nebakanerer solution works for the root of the site, it does not work for any URLs that offered subfolders.

Default.aspx, - IIS6 aspnet_isapi.dll. , ASP.NET .

: [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]

+3

Source: https://habr.com/ru/post/1713726/


All Articles