用特殊字符重写网址 [英] Url Rewriting with special characters
问题描述
你好朋友,
我一直在为我的ASP.NET(3.5)Web应用程序使用Url Rewriting.我正在跟踪 global.asax的Application_BeginRequest 事件,并已将非常简单的URL成功映射到了我的Web应用程序中的相应网页.
网址映射成功
http://myserver/abc.htm ,我可以轻松地将其映射到 http://myserver/default.aspx
使用 Context.Rewrite 路径.
当我想在Urls中使用特殊字符或通配符时,这种方法就会出现问题,例如
http://myserver/a:bc.htm提供(HTTP错误400-错误的请求)
http://mysever/abc..htm提供(HTTP错误400-错误的请求)
http://myserver/abc?.htm提供(HTTP错误400-错误的请求)
即使我将Urls编码为
http://myserver/a%3Abc.htm(HTTP错误400-错误的请求.)
请帮助我,因为应用程序需要这些Urls.
谢谢
Hello Friends,
I have been working with the Url Rewriting for my ASP.NET (3.5) web application. I am following the global.asax ''s Application_BeginRequest event and have succcessfully mapped very simple urls to the appropriate web page in my web application.
Urls mapped successfully
http://myserver/abc.htm and I can easily map this to http://myserver/default.aspx
with Context.Rewrite Path.
The problem arises with this method when I want to use special characters or wild card characters in my Urls e.g
http://myserver/a:bc.htm gives( HTTP Error 400 - Bad Request )
http://mysever/abc..htm gives(HTTP Error 400 - Bad Request )
http://myserver/abc?.htm gives(HTTP Error 400 - Bad Request )
and even if i encode my Urls as
http://myserver/a%3Abc.htm (HTTP Error 400 - Bad Request.)
Please help me out as application needs these kind of Urls to be there.
Thanks
推荐答案
在配置文件中尝试此设置
Try this setting in config file
<system.web>
<httpRuntime requestPathInvalidCharacters="" requestValidationMode="2.0" />
<pages validateRequest="false" />
</system.web>
这篇关于用特殊字符重写网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!