Search code examples
asp.netasp.net-routing

URL Routing with ASP.NET 4 Web Forms


I have ASP.NET webFroms application on my local, when i try to use this following rout I get 404 not found error. I am trying to go to mylocalsite.com/home that should resolve to ~/Default.aspx, what can be the issue? I did try many ways and followed on MSDN help on http://msdn.microsoft.com/en-us/library/cc668202.aspx but cant make it to work so that I can create the routs that i need. the site is running on IIS7.

this following code is in my Global.asax

public static void RegisterRoutes(RouteCollection routes)
        {

            routes.MapPageRoute("homepage", "/home", "~/Default.aspx");

        }

        protected void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes(RouteTable.Routes);


        }

Solution

  • thanks for all of your help, and I finally found what was my exact problem, you can see it in below link, my main issue was HTTP Redirection feature was not enabled in windows features --> World wide web Services --> Common HTTP Features --> HTTp Redirection

    full steps for fix: ASP.NET 4.0 URL Routing HTTP Error 404.0 - Not Found