Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Hi.
 
i want to route url using route handler i tried some code but it doesn't work out.
 
in Global page:
 
   RouteTable.Routes.Clear();
        RouteTable.Routes.Add("MyCustomRoute", new Route("{Name}", new CustomRouteHandler("~/Index.aspx")));
 
and the class which implements handler is
 
public class CustomRouteHandler : IRouteHandler {
 
  
    IHttpHandler IRouteHandler.GetHttpHandler(RequestContext requestContext)
    {
        string virtualPath = "~/Index.aspx";
 
        return BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(Page)) as IHttpHandler;
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }
 
}
 
in index page:
 
 string a =(string) Page.RouteData.Values["Name"];
i am trying for this since four days. i cant able to understand where i am going wrong...please help me.the same code i tried in another project it is working there. i cant able to do it in my project..
 
Error: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
 
Thanks in advance..
Posted 18-Jan-13 20:01pm
074051.1K
Edited 18-Jan-13 21:15pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

your problem is not so much clear.
in some case regarding URL rewriting when your rewrite URL point to none exists physical page then 404 problem occured. and this problem can be solved by
add this tag in your web.config file
 
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
...
</modules>
</system.webServer>
 
http://codingsack.com/question/5/global.asax-application-beginrequest-not-firing-problem-occurs-during-.html[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Peter Leow 390
1 Sergey Alexandrovich Kryukov 330
2 Zoltán Zörgő 258
3 CHill60 195
4 CPallini 155
0 Sergey Alexandrovich Kryukov 8,943
1 OriginalGriff 6,631
2 Peter Leow 4,102
3 Zoltán Zörgő 3,714
4 Kornfeld Eliyahu Peter 2,525


Advertise | Privacy | Mobile
Web04 | 2.8.150123.1 | Last Updated 20 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100