从客户端检测到潜在危险的Request.Path值

时间:2014-12-04 16:13:54

标签: c# asp.net .net asp.net-mvc

我在我的Login API中制作了一个简单的RedirectToAction,我收到了这个错误:

A potentially dangerous Request.Path value was detected from the client (<).

我一直在搜索,我发现我必须在requestPathInvalidCharacters添加Web.config,就像这样:

<httpRuntime targetFramework="4.5" requestPathInvalidCharacters="" executionTimeout="54000" maxRequestLength="512000" />
<authentication mode="Forms">
  <forms loginUrl="~/" timeout="2880" />
</authentication>
<pages>
  <namespaces>
    <add namespace="System.Web.Helpers" />
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Optimization" />
    <add namespace="System.Web.Routing" />
    <add namespace="System.Web.WebPages" />
  </namespaces>
</pages>

但现在我的错误是:

A potentially dangerous Request.Path value was detected from the client (="/<!DOCTYPE html><html...").

产生错误的代码:

//part of Auth/FacebookLogin
if (error == LoginErrorCodes.UserBanned)
{
    return RedirectToAction("Banned", "Home");
}

这就是这个:

//At HomeController
public ActionResult Banned()
{
    return View();
}

0 个答案:

没有答案