Extending Asp.Net MVC Routing Mechanism

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

I posted a related question about the problem I had.

The essence of the problem is that routes that end on. (period) are never handled by the default routing engine. The error "Resource cannot be found" is always raised. 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 a querystring parameter like this, it works fine:

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

I am trying to find an extension point in a routing mechanism that will help me solve this problem. I 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 );
      }
}

, Response.Redirect Server.Transfer , MVC RedirectToAction . , .

, Apache, Wikipedia . http://en.wikipedia.org/wiki/Washington,_D.C. - , .

+3
1

, ?

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");
+1

Source: https://habr.com/ru/post/1709684/


All Articles