클라이언트에서 잠재적으로 위험한 Request.Form 값이 감지되었습니다 (editor = "<div id ="header "sty ...").

타임스

우선 나는 거의 모든 질문과 포럼 게시물을 따랐다 고 말해야합니다.

Stackoverflow 질문 1

Stackoverflow 질문 2

Stackoverflow 질문 3

Stackoverflow 질문 4

aspsnippets.com

응용 프로그램의 서버 오류 ... 잠재적으로 위험한 Request.Form 값이 감지되었습니다.

'잠재적으로 위험한 Request.Form 값이 감지되었습니다'방지

c-sharpcorner.com

asp.net의 클라이언트에서 잠재적으로 위험한 Request.Form 값이 감지되었습니다.

web.config 파일 을 추가 <httpRuntime requestValidationMode = "2.0" />하거나 <pages validateRequest ="false" />내부에 언급 된 모든 스레드 ,하지만 이것은 나를 위해 작동하지 않습니다.

일단 그렇게하고 디버깅을 시작하면 이런 종류의 오류가 발생합니다.

여기에 이미지 설명 입력

실제로 리치 텍스트 편집기 콘텐츠에 HTML 파일을로드 한 다음 PDF로 저장 버튼을 클릭하면 해당 리치 텍스트 편집기 콘텐츠를 PDF 파일로 저장합니다.

이들은 관련 컨트롤러 클래스 메서드입니다.

   [ValidateInput(false)]  
      public ActionResult output_xhtml()  
      {  
          PrepairEditor(delegate(Editor editor)  
          {  
              editor.LoadHtml("~/example.html");  
          });  
          return View();  
      }  

      [HttpPost]  
      [ValidateInput(false)]  
      public ActionResult output_xhtml(string m)  
      {  
          Editor theeditor = PrepairEditor(delegate(Editor editor)  
          {  

          });  

          theeditor.SavePDF("~/aaa.pdf");  

          return View();  
      }

PrepairEditor () 메서드

protected Editor PrepairEditor(Action<Editor> oninit)  
  {  
      Editor editor = new Editor(System.Web.HttpContext.Current, "editor");  

      editor.ClientFolder = "/richtexteditor/";  
      editor.ContentCss = "/Content/example.css";  
      //editor.ClientFolder = "/Content/richtexteditor/";      
      //editor.ClientFolder = "/Scripts/richtexteditor/";      

      editor.Text = "Type here";  

      editor.AjaxPostbackUrl = Url.Action("EditorAjaxHandler");  

      if (oninit != null) oninit(editor);  

      //try to handle the upload/ajax requests      
      bool isajax = editor.MvcInit();  

      if (isajax)  
          return editor;  

      //load the form data if any      
      if (this.Request.HttpMethod == "POST")  
      {  
          string formdata = this.Request.Form[editor.Name];  
          if (formdata != null)  
              editor.LoadFormData(formdata);  
      }  

      //render the editor to ViewBag.Editor      
      ViewBag.Editor = editor.MvcGetString();  

      return editor;  
  }  

  //this action is specified by editor.AjaxPostbackUrl = Url.Action("EditorAjaxHandler");      
  //it will handle the editor dialogs Upload/Ajax requests      
  [ValidateInput(false)]  
  public ActionResult EditorAjaxHandler()  
  {  
      PrepairEditor(delegate(Editor editor)  
      {  

      });  
      return new EmptyResult();  
  }  

PrepairEditor () 메서드에서 오류가 발생한 곳의 스크린 샷입니다.

여기에 이미지 설명 입력

output_xhtml.cshtml 보기 파일

<!DOCTYPE html>
<html>
<head>
    <title>RichTextEditor - Output XHTML</title>    
</head>
<body>

    <script type="text/javascript">

    var editor;

    function RichTextEditor_OnLoad(editor) {
        editor = editor;
            var content = true;
            if (!content) {
                setTimeout(function () {
                    editor.SetText("<table>.....</table>");
                }, 1000);
                return;
            }
        }

    </script>


    <script type='text/javascript'>

    function RichTextEditor_OnLoad(editor) {
        editor.SetWidth(1150); //Sets the width.
        editor.SetHeight(612); //Sets the height.
    }

    </script>

    @using (Html.BeginForm())
    {           

            <div>
                @Html.Raw(ViewBag.Editor)
                <br />
                <button id="btn_sumbit" type="submit" class="btn btn-danger submit">Save as PDF</button>                   
            </div>
            <br />
            <div>
                <h3>
                    Result html:
                </h3>
                <div>
                    @ViewBag._content
                </div>
            </div>
    }
</body>
</html>  
사용자 743382

일단 그렇게하고 디버깅을 시작하면 이런 종류의 오류가 발생합니다.

당신이 받고있는 오류를보십시오. <httpRuntime />web.config에 이미 섹션이 있습니다. 둘 중 하나를 가질 수 없습니다. 새 항목을 추가하는 대신 기존 항목을 변경하십시오.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관