IIS 6 not allowing periods in the querystring

我只是一个虾纸丫 提交于 2019-12-23 23:44:05

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!