ASP.Net MVC: How to use a virtual path (directory) with a dot (period)?
If I create a new MVC web application project, build and run it the home page comes up as expected. However, if you change the project's Web Properties to use a "Virtual Path" that contains a dot (for example: "Version1.2"), it will fail to work ("The resource cannot be 开发者_如何转开发found.").
What options are there?
Using something else instead of a dot, maybe? ;)
Custom Route class
You could write custom route class and provide you own functionality that will be able to consume URLs with dots. But be warned: writing a custom Route class requires a bit deeper understanding of Asp.net routing than just routes.MapRoute()
.
I've done a custom Route class in the past. It serves a different purpose, but you can check it out. Maybe it will lighten things up a bit for you. Click this link and check it out.
If the URL is automatically generated you could add a slash at the end of the url. Ending the URL with a slash prevents the routing system from trying to look it up as a file even though the last component of the URL contains a dot.
For example, use this URL :
http://www.example.com/version1.2/
精彩评论