Directly accept HTML content fragments sent by the client in the action of ASP.

Source: Internet
Author: User

For security reasons, by default, if the HTML content is directly included in the data sent from the client, ASP. NET will automatically start protection, you will receive the following error message

This is certainly a nice design, but in certain special things, if we do need to accept the HTML sent by the client, then we need to make some necessary changes

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;

Namespace Emreditor.controllers
public class Homecontroller:controller
Public ActionResult Index ()
return View ();

[ValidateInput (false)]
Public ActionResult Index ()
var req = Request.Form;
Return content (req["content"]);

Then, in Web. config, you also need to configure

<compilation debug= "true" targetframework= "4.5.2"/>
requestvalidationmode= "2.0"/>

Directly accept HTML content fragments sent by the client in the action of ASP.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.