c# - A potentially dangerous Request.Form value was detected from the client (editor="<div id="header" sty...") -
first of should have followed questions , forum post below
server error in application ... potentially dangerous request.form value detected
avoiding ‘a potentially dangerous request.form value detected’
a potentially dangerous request.form value detected client in asp.net
all thread mentioned add <httpruntime requestvalidationmode = "2.0" />
or <pages validaterequest ="false" />
inside web.config file , isn't working me .
once did , start debugging , getting kind of error
actually i'm trying loading html file rich text editor content once click save pdf button saving rich text editor content pdf file
these relevant controller class methods
[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() method
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 handle upload/ajax requests bool isajax = editor.mvcinit(); if (isajax) return editor; //load form data if if (this.request.httpmethod == "post") { string formdata = this.request.form[editor.name]; if (formdata != null) editor.loadformdata(formdata); } //render editor viewbag.editor viewbag.editor = editor.mvcgetstring(); return editor; } //this action specified editor.ajaxpostbackurl = url.action("editorajaxhandler"); //it handle editor dialogs upload/ajax requests [validateinput(false)] public actionresult editorajaxhandler() { prepaireditor(delegate(editor editor) { }); return new emptyresult(); }
this screenshot of error occurring place in prepaireditor() method
output_xhtml.cshtml view file
<!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 width. editor.setheight(612); //sets height. } </script> @using (html.beginform()) { <div> @html.raw(viewbag.editor) <br /> <button id="btn_sumbit" type="submit" class="btn btn-danger submit">save pdf</button> </div> <br /> <div> <h3> result html: </h3> <div> @viewbag._content </div> </div> } </body> </html>
once did , start debugging , getting kind of error
look @ error getting. have <httpruntime />
section in web.config. can't have 2 of them. instead of adding new one, change existing one.
Comments
Post a Comment