3

I've found a limitation in the routing mechanism for ASP.Net mvc and I'm trying to find a workaround.

I posted a related question here about the issue I was having.

The gist of the problem is that routes that end with a . (period) are never handled by the default routing mechanism. A "Resource Cannot Be Found" error is always thrown. For example it cannot handle these urls:

http://www.wikipediamaze.com/wiki/Washington,_D.C.
http://www.wikipediamaze.com/wiki/anythingendinglikethis.

if I change it to querystring parameter like this it works fine:

http://www.wikipediamaze.com/wiki/?topic=Washington,_D.C.

I'm trying to find an extensibility point in the routing mechanism that will help me resolve this issue. I've tried other solutions like this:

//Global.asax.cs
protected void Application_Error()
{
     var url = HttpContext.Current.Request.RawUrl;
     if(TopicRegex.IsMatch(url))
     {
         var fixedUrl = FixUrlPath(url);

         //This throws an error
         Response.Redirect(fixedUrl);

         //This also throws an error
         Server.Transfer(fixedUrl );
      }
}

I'm guessing that the Response.Redirect and Server.Transfer throw errors because in MVC you should be calling the RedirectToAction methods from the controller. Of course I can't even get to the controller.

This seems to be a pretty big limitation considering the Apache server that Wikipedia uses handles this just fine. try it out http://en.wikipedia.org/wiki/Washington,_D.C. If anyone could please offer some help here I would appreciate it.

2
  • Trying it out myself, I'm seeing periods being passed in without any problem. Could you post an example of the routes you're defining and the controllers they map to? Commented Jun 3, 2009 at 17:33
  • stackoverflow.com/questions/429963/… Commented Jun 3, 2009 at 17:50

1 Answer 1

1

Could you turn of checking file exists in the routes but allow certain extensions through?

routes.RouteExistingFiles = true;

// Ignore the assets directory which contains images, js, css & html
routes.IgnoreRoute("Assets/{*pathInfo}");

// Ignore text, html, files.
routes.IgnoreRoute("{file}.txt");
routes.IgnoreRoute("{file}.htm");
routes.IgnoreRoute("{file}.html");
routes.IgnoreRoute("{file}.aspx");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.