Lets Have a fun with Technology.

BTemplates.com

Follow by Email

Friday, March 25, 2016

Significant of routes.IgnoreRoute in MVC Application.


Hello,

In MVC Application, RouteConfig.cs file have a RegisterRoutes method.

This method is give facility to not process some files by the asp.net mvc engine.




public static void RegisterRoutes(RouteCollection routes)

{

  routes.IgnoreRoute("{resource}.axd/{*pathInfo}");



}


This will match requests to resources like /Manager.axd or /a.axd/b/c.aspx,
but will not match a request to any *.axd resource below the root of your site like /a/b/c.axd

The following works for files in the root:



routes.IgnoreRoute("{file}.css");

routes.IgnoreRoute("{file}.jpg");

routes.IgnoreRoute("{file}.gif");


If you want to ignore files in a specific directory, you can do this:



routes.IgnoreRoute("Folder/{*pathInfo}");


1 comment:

  1. Hi,Nice update on MVC application. RouteConfig.cs file have a Register Routes method,which gives facility to not process some files by the asp.net mvc engine. Along with the upgraded version of MVC hosting, many updated features and attributes have been included.

    ReplyDelete