On my dev box, I'm able to register Routes during Application_Start in Global.asas and handle the routes using TheURLRouter class. It doesn't work DASP servers. I've restarted the App through IIS in an effort to ensure that the Application_Start method is called to no avail. Has anybody had this problem or tried to implement URL rewriting in this manner? Thanks in advance. //--GLOBAL.ASAX protected void Application_Start(object sender, EventArgs e) { RegisterRoutes(RouteTable.Routes); } private void RegisterRoutes(RouteCollection Routes) { Route r = new Route("{Page}", new TheURLRouter()); Route r1 = new Route("{Page}/{Param1}", new TheURLRouter()); Routes.Add("SimplePage",r); Routes.Add("PageWithParameter", r1); } //--TheURLRouter.cs The TheURLRouter exists in my App_Code directory and looks implements IRouteHandler public class TheURLRouter : IRouteHandler { public IHttpHandler GetHttpHandler(RequestContext requestContext) { //handles the routing ... } }
I get a Page Cannot Be Found error. Below is a snippit from my URLRouter. Using IIS document defaults www.domain.com brings up Default.aspx, and I can access the page by directly typing in the page name. But www.domain.com/Home can't find the page. It works on my Visual Studio 2008 local server. I've also put redirect code in my global.aspx Session_Start and Application_Start to see if either of the global.asax file is getting called but the redirects never occur. DASP support told me this "When your application is started the application_start method is indeed run. Recycling, restarting, or running an application for the very first time on the server have the same effect." I've recycled, restarted and waiting more than 20 minutes for the app to expire hoping I could get the application_start method to be invoked with no luck. I'm struggling to find ways to troubleshoot this issue. //re-routing home to Default.aspx pageName = pageName.ToLower() == "home" ? "Default" : pageName; if (pageName.ToLower().Equals("default")) { virtualPath += string.Format("{0}.aspx", pageName); } ... return (Page)BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(Page));
Are you hosted on an IIS6 server? You'll need to request support to create a wildcard mapping to point to asp.net isapi.
integrated. FYI - I've downloaded and installed the MS IIS config tool so I can change mode if I need to.
routing doesn't workfor me either did you get this solved? i have the same problem. it works on my dev box but not at discountasp.net
still can't get this working the url rewriting works on my local development box using the asp.net development server. but when i upload i get "internal server error 500". if anyone has the asp.net routing working i'd appreciate a web.config snippet. also do you have to configure iis in any special way? quite frustrating. i then tried using "copy local" on the system.web.routing dll and now i get page-not-found errors. do i need to do a copy-local on any of the asp.net assemblies?
got it working! not sure what i did but it seems to work now. i had a duplicate line in the web.config. i did a "copylocal" on the routing.dll. i restarting the application pool.
For future reference, I was having this problem as well and was finally able to fix it. The thing that ended up working for me was going into "IIS Tools" on the Control Panel and changing the "Application Pool Pipeline Mode" to "Classic" - and boom... it started working.