asp.net mvc routing, ignore route with extension in the middle of url
Hi How can make the asp.net routing engine ignore routes with an exten开发者_Python百科sion of the type /pathtofile/filename.aspx/morepaths
I know this is hardly a real scenario but I need to know for another similar issue for an autogenerated url Thanks
The MVC routing engine will not intercept a url if there is a matching file on the file system. (See RouteCollection.Ignore Method) So your example url will work fine. Query strings will also work fine.
You can test this out as follows:
- Create an MVC application in Visual Studio
- Run it
- In your browser enter the url of the Site.css file in the Contents folder.
- The file will be served and the browser will pop up the "Save" dialog.
- Create an html file anywhere on the site and enter the url.
- Your browser will display the html page.
- Create an aspx web form anywhere on the site and enter the url.
- Your browser will display the web form.
- Add a query string or additional path to the url.
- Your browser will display the web form.
You can also do this with .asp (classic ASP) pages (although the VS web server won't serve .asp pages, you have to set the site up in IIS for that to work.)
I hope that answers your question.
精彩评论