获得""从客户端(AMP)中检测到有潜在危险的Request的价值; [英] Getting "A potentially dangerous Request.Path value was detected from the client (&)"

查看:126
本文介绍了获得""从客户端(AMP)中检测到有潜在危险的Request的价值;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求,我支持随机的网址,如果他们的主页的请求的传统code问题。一些URL,在他们产生错误的字符从客户端检测到有潜在危险的Request的值(安培) 。该网站是写与ASP.Net MVC 3(在C#)和IIS 7.5上运行。

I've got a legacy code issue that requires that I support random urls as if they were requests for the home page. Some of the URLs have characters in them that generate the error "A potentially dangerous Request.Path value was detected from the client (&)". The site is written with ASP.Net MVC 3 (in C#) and is running on IIS 7.5.

下面是一个例子网址...

Here's an example URL...

http://mywebsite.com/Test123/This_&_That

下面就是我有我的包罗万象的路线设置(我有其他途径捕获特定页)...

Here's how I have my catch-all route setup (I have other routes to catch specific pages)...

routes.MapRoute(
    "Default", // Route name
    "{garb1}/{garb2}", // URL with parameters
    new { controller = "Website", action = "Home", garb1 = UrlParameter.Optional, garb2 = UrlParameter.Optional } // Parameter defaults
);

我添加下面的东西到我的web.config文件...

I've added the following things to my web.config file...

<configuration>
    <system.web>
        <pages validateRequest="false" />
        <httpRuntime requestValidationMode="2.0" />
    </system.web>
<configuration>

我还添加了ValidateInput属性应醒目的URL的动作...

I've also Added the ValidateInput attribute to the action that should be catching the urls...

public class WebsiteController : Controller
{
    [ValidateInput(false)]
    public ActionResult Home()
    {
        return View();
    }
}

但我仍然得到错误。任何想法,为什么?我错过了什么?现在我只是在我的本地开发服务器上运行的(我还没有尝试在生产这些修补程序还)。

But I'm still getting the error. Any ideas why? Did I miss something? Right now I'm just running on my local dev server (I haven't tried these fixes in production yet).

推荐答案

虽然你可以尝试在配置文件中这些设置

While you could try these settings in config file

<system.web>
    <httpRuntime requestPathInvalidCharacters="" requestValidationMode="2.0" />
    <pages validateRequest="false" />
</system.web>

我会避免使用类似的字符'和;'在URL路径用下划线替换它们。

I would avoid using characters like '&' in URL path replacing them with underscores.

这篇关于获得&QUOT;&QUOT;从客户端(AMP)中检测到有潜在危险的Request的价值;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆