Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

system.web.routing on a web server not working

I have read all these articles about how to make system.web.routing work but all these articles explains on localhost:port. I can get this working on the local machine, but as soon as I upload the site on the server, the Routing stops working no matter what I do.

First I was trying without any extension (.aspx) but after all efforts I gave up and added the extension, but still it does not work on the server.

Any help is appreciated.

sample:

in global.ascx

Route test = new Route("home.aspx", new TestRoutingHandler());
Routes.Add(test); 

in Routing handler

public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
    string virtualPath = string.Empty;
    Route route = (Route)requestContext.RouteData.Route;
    virtualPath = "~/Default.aspx";
    return (Page)BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(Page));
}

In web.config under httpModules

add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" 

This is so simple and works on a local machine, but not on the web server.


1 Answers

For IIS7+ i found adding to the web.config's section suddenly made everything work:

<modules runAllManagedModulesForAllRequests="true" />

Confusing as in VS running on the Cassini web server, it worked just fine.

like image 92
bigtv Avatar answered Mar 16 '26 14:03

bigtv



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!