Question

I have followed a few tutorials online and they all seem to show the same logic for .net routing using ASP.net web forms. When I execute the URL below I get a 404 error. Test.aspx is in the root folder of this application.

http://www.mydomain.com/member/abc

Here is my global.asax contents:


<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Routing" %>

<script runat="server">

    void RegisterRoutes(RouteCollection routes)
    {
        routes.MapPageRoute(
            "TestABC",
            "member/{name}",
            "~/Test.aspx");
    }               

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

    void Application_End(object sender, EventArgs e) 
    {
        //  Code that runs on application shutdown

    }

    void Application_Error(object sender, EventArgs e) 
    {

    }

    void Session_Start(object sender, EventArgs e) 
    {
        // Code that runs when a new session is started

    }

    void Session_End(object sender, EventArgs e) 
    {
        // Code that runs when a session ends. 
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer 
        // or SQLServer, the event is not raised.

    }

</script>

Is there something I need to do with my web.config file?

Any help is greatly appreciated.

Was it helpful?

Solution

I'm guessing that your routing module is not triggered when you hit the iis server. As a test to verify that this is the cause : change your webconfig to run all managed modules upon a request. You need to set this :

<modules runAllManagedModulesForAllRequests="true">

If that solved it you can go read this resource on why to not do that :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top