0
votes

Greetings,

I am using Visual Studio 2010 and ASP.NET 4.0 to build a WebForms project that uses the new routing features in System.Web.Routing. When I build my solution and run it from within VS.NET's debugging environment only routes with RouteUrl's that include a ".aspx" extension are being properly routed to the PhysicalFile. It appears requests made to other URLs are not being "detected" by the routing engine for processing. In the case below, "Scenario1" shows a 404 and "Scenario2" works properly.

I would greatly appreciate any guidance you can provide.

Here is the relevant code in my global.asax:

void Application_Start(object sender, EventArgs e)
{
    // Code that runs on application startup

    // Register Routes
    RegisterRoutes();
}

void RegisterRoutes()
{
    System.Web.Routing.RouteTable.Routes.MapPageRoute("Scenario1", "scenario1/{option1}", "~/About.aspx");  
    System.Web.Routing.RouteTable.Routes.MapPageRoute("Scenario2", "scenario2.aspx", "~/About.aspx");
}

Thank you kindly for your time.

MomentSurfer

1

1 Answers

1
votes

I found the issue to my problem after reading this post:

Asp.Net System.Web.Routing won't route URL unless .aspx in on the end

My VS2010 solution contains several projects: web, business layer classes, data access layer classes, etc. My web project was called "SystemName.WebForms". The period in the web project name interferes with ASP.NET 4.0's WebForm's routing for some strange reason. Once I renamed my project to "SystemName_WebForms" all of the routes work correctly.

WITH A PERIOD IN THE WEB PROJECT NAME:

  • only "scenario2" and "scenario4" work

WITHOUT A PERIOD IN THE WEB PROJECT NAME:

  • all scenarios work

ROUTES:

    RouteTable.Routes.MapPageRoute("scenario1", "scenario1/{option1}", "~/About.aspx");
    RouteTable.Routes.MapPageRoute("scenario2", "scenario2.aspx", "~/About.aspx");
    RouteTable.Routes.MapPageRoute("scenario3", "scenario3", "~/About.aspx");
    RouteTable.Routes.MapPageRoute("scenario4", "scenario4.xxx", "~/About.aspx");

Many thanks to @vincentw56 for finding and posting the answer to his question!!

MomentSurfer