Programming

“클라이언트 (&)에서 잠재적으로 위험한 Request.Path 값을 발견했습니다”

procodes 2020. 7. 27. 21:38
반응형

“클라이언트 (&)에서 잠재적으로 위험한 Request.Path 값을 발견했습니다”


임의의 URL을 마치 홈페이지에 대한 요청 인 것처럼 지원해야하는 레거시 코드 문제가 있습니다. 일부 URL에는 "클라이언트 (&)에서 위험한 잠재적 Request.Path 값이 발견되었습니다" 라는 오류가 발생하는 문자가 있습니다 . 이 사이트는 ASP.Net MVC 3 (C #)으로 작성되었으며 IIS 7.5에서 실행됩니다.

URL 예는 다음과 같습니다.

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

다음은 catch-all 경로 설정 방법입니다 (특정 페이지를 잡을 수있는 다른 경로가 있습니다).

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 파일에 다음 사항을 추가했습니다 ...

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

또한 URL을 잡는 액션에 ValidateInput 속성을 추가했습니다 ...

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

그러나 여전히 오류가 발생합니다. 어떤 아이디어가 있습니까? 내가 뭐 놓친 거 없니? 지금은 로컬 dev 서버에서 실행 중입니다 (프로덕션 에서이 수정 프로그램을 아직 시도하지 않았습니다).


구성 파일에서 이러한 설정을 시도 할 수 있지만

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

URL 경로에 '&'와 같은 문자를 밑줄로 바꾸지 마십시오.


이 유형의 오류에 직면했습니다. 면도기에서 함수를 호출합니다.

public ActionResult EditorAjax(int id, int? jobId, string type = ""){}

줄을 바꿔서 해결

...에서

<a href="/ScreeningQuestion/EditorAjax/5&jobId=2&type=additional" /> 

<a href="/ScreeningQuestion/EditorAjax/?id=5&jobId=2&type=additional" />

내 route.config는

routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional }, new string[] { "RPMS.Controllers" } // Parameter defaults
        );

mvc의 텍스트 상자에 대해서만 HTML 태그를 허용하려는 경우

당신은 한 가지를 할 수 있습니다

컨트롤러에서

 [ValidateInput(false)]
public ActionResult CreateNewHtml()  //view
{
    return View();
}
[ValidateInput(false)]
[HttpPost]
public ActionResult CreateNewHtml(cbs obj)//view cbs is database class
{
    repo.AddHtml(obj);
    return View();
}

We were getting this same error in Fiddler when trying to figure out why our Silverlight ArcGIS map viewer wasn't loading the map. In our case it was a typo in the URL in the code. There was an equal sign in there for some reason.
http:=//someurltosome/awesome/place
instead of
http://someurltosome/awesome/place

After taking out that equal sign it worked great (of course).


Check the below lines are present in your web.config file

<system.web> <httpRuntime requestPathInvalidCharacters="" /> </system.web>

참고URL : https://stackoverflow.com/questions/6025522/getting-a-potentially-dangerous-request-path-value-was-detected-from-the-client

반응형