开发者

Specificying a Page directive attribute on an NHaml page

开发者 https://www.devze.com 2022-12-26 16:49 出处:网络
I am working on an MVC site using NHaml for the view engine. I have a page that needs to submit HTML code as a form value and am getting the System.Web.HttpRequestValidationException thrown at me.

I am working on an MVC site using NHaml for the view engine.

I have a page that needs to submit HTML code as a form value and am getting the System.Web.HttpRequestValidationException thrown at me.

I want to specify the <%@ Page validateRequest="false" %> so that this pag开发者_Python百科e will allow this data to be submitted but am unsure on how to do this with NHaml generating the pages.

Side note on this:

The editor I was using was TinyMCE and I found that it has an option for encoding the output, that way it doesn't trigger the anti-html validation.

Of course, then your value is encoded so you have to make sure to decode it at the proper time.

See http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/encoding


You may try annotating your controller action with the ValidateInputAttribute:

[ValidateInput(false)]
public ActionResult Index()
{
    // ...method body
}

This could also be done in the config file for the whole application:

<configuration>
   <system.web>
      <pages validateRequest="false" />
   </system.web>
</configuration>
0

精彩评论

暂无评论...
验证码 换一张
取 消