出于安全的考虑,默认情况下,如果从客户端发送过来的数据中直接包括了HTML内容,ASP.NET会自动启动保护措施,这当然是一个比较好的设计,只不过在某种情况下我们真的需要获取这个值,那我们应该怎么办呢。
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;namespace EMREditor.Controllers{ public class HomeController : Controller { // GET: Home //public ActionResult Index() //{ // return View(); //} [HttpPost] [ValidateInput(false)] public ActionResult Index() { var req = Request.Form; return Content(req["content"]); } }}
然后,在web.config中还需要配置