问题
I am doing a bad thing here. I am asking a question without trying out first by hopping that someone knows an easy way of doing this.
Any chance we can make ASP.NET MVC Routing system case sensitive? I would like the following two Urls to be different:
example.com/a
example.com/A
Do we have an easy fix or should write our own handler for this.
回答1:
I haven't tried it, but I would think that if you use a regular expression route constraint that only matched the uppercase and lowercase seperate, that would work. I don't think it's a good idea though.
回答2:
That seems like a bad idea. You're assuming that folks will never touch a url by hand, always clicking links.
Plus, by default, MSSQL is case insensitive, assuming that some of your route values are database bound.
I'd also be willing to bet that all urls in the search engines are lower case( Edumacated guess ).
EDIT
All google paid search urls are lower case.
If you STILL insist on doing this:
You also may have to have implement a custom viewengine that looks for the views on a case sensitive basis. Also a custom controller factory to find controllers that are case sensitive.
回答3:
Also note that regex options like case sensitivity can be changed mid regex by things like:
...(?-i:nonCaseSensitiveBit)backToCaseInsensitive...
See the Regex docs for the full readout.
来源:https://stackoverflow.com/questions/9518064/asp-net-mvc-3-case-sensitive-urls