问题
I have deployed an asp.net site with a wcf rest service to a virtual directory. It accepts lat/lon in the querystring. IIS is apparently not allowing querystrings that contain a '.'. I have found numerious posts on the topic, but cannot seem to resolve the issue.
I have tried enabling parent paths on both the parent website and the virtual directory: http://support.microsoft.com/kb/332117
I have already tried the httpRuntime setting for relaxedUrlToFileSystemMapping="true" http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in-URLs.aspx
currently I have both parent paths enabled and my httpRuntime settings are:
<httpRuntime requestValidationMode="2.0" requestPathInvalidCharacters="" relaxedUrlToFileSystemMapping="true" />
回答1:
I noticed that the Urls you were using have a / rather than a ? which causes the elements to be treated as a path rather than a query string.
If that was intended and you are using .NET 4.0, you can try using the <schemeSettings> Element (Uri Settings) under configuration:
<uri>
<schemeSettings>
<add name="http" genericUriParserOptions="DontUnescapePathDotsAndSlashes" />
</schemeSettings>
</uri>
See GenericUriParserOptions Enumeration for the valid values.
If that was not intended update your template to use the ? mark and you should be ok:
[WebGet(UriTemplate = "?username={username}&lat={lat}&lng={lng}")]
回答2:
Probablly not what you were looking for but I would use UrlEncode:
http://msdn.microsoft.com/en-us/library/zttxte6w.aspx
来源:https://stackoverflow.com/questions/9336569/iis-6-not-allowing-periods-in-the-querystring