0

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.

alockrem
  • 767
  • 3
  • 9
  • 23
  • Did you create the global.asax by yourself? Why are there script tags in there? – Kristof Nov 27 '12 at 13:30
  • I right clicked on my project in solution explorer and added a new item. I selected a global.asax file and that's what it gave me. How should it be changed to work correctly? – alockrem Nov 27 '12 at 13:31
  • what .NET version and mvc version are you using? – Kristof Nov 27 '12 at 13:33
  • It is not an MVC model. Web forms version 4.0. – alockrem Nov 27 '12 at 13:34
  • My bad, misread that. Apparently you can use the script tags version of the global.asax to avoid using a codebehind file. So that should be okay. – Kristof Nov 27 '12 at 13:36

1 Answers1

0

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 :)

Kristof
  • 3,267
  • 1
  • 20
  • 30
  • That worked! Thank you very much. I also followed the resource provided which also worked. Thank you for all of your help. – alockrem Nov 27 '12 at 17:17