开发者

asp.net mvc routing, ignore route with extension in the middle of url

开发者 https://www.devze.com 2023-01-15 14:54 出处:网络
Hi How can make the asp.net routing engine ignore routes with an exten开发者_Python百科sion of the type

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号