ASP.Net MVC: Excluding spaces from urls with reque

2019-08-04 08:04发布

In my ASP MVC site on IIS7.5, and have set a long maxUrlLength in order to handle urls longer than 260 characters. For this we also have to turn on relaxedUrlToFileSystemMapping.

So we have this in the web.config:

<httpRuntime enableVersionHeader="false" maxUrlLength="1200" 
  relaxedUrlToFileSystemMapping="true"
  requestPathInvalidCharacters="&lt;,&gt;,&amp;,*,%,:,;,\,?,%" />

A side-efect is that no urls that end with a space and a slash are now valid. e.g. "http://mysite.com/path/to/name /" used to throw a HttpException that we caught and issued a 301 redirect. But now it does not.

Is it possible to make this url behave as before? Can I specify the space character in the requestPathInvalidCharacters list somehow? Putting in requestPathInvalidCharacters=" " has no effect on spaces in urls, and neither does requestPathInvalidCharacters="&#32;". and requestPathInvalidCharacters="%20" is a configuration error.

0条回答
登录 后发表回答