Sunday, July 18, 2010 4.0 Url Routing

In 4.0 , New functionality included for URL Routing.

For Example : ( Application_Start)

When Browser request for http://<<your site>>/Home, It will route to page Default.aspx

And Page has some property that allow you to get route data, Page.RouteData

Even generic route is also possible.


Now When request made for Url : http://<<yoursite>/Test It automatically route to Test.aspx

One more thing true about 4.0 routing is even though routing is done, there is still possible that direct request for “ASPX” pages.

To disable that

1. from UI (IIS 7.0 or later)
       - Go to inetmgr
       - In Feature View go to “Request Filtering”
       - Click Deny FileName Extension 

2.  Using main web.config file of your application          
     <modules runAllManagedModulesForAllRequests="true" />
                    <add fileExtension=".aspx" allowed="false" />
    - Add Module tag with runAllManagedModulesForAllRequests = “true”
    - Add requestfiltering with fileextension=”.aspx” and “allowed=false”.

Let me know your comment on this.

No comments: