现在的位置: 首页 > 综合 > 正文

VS2010使用.net 4.0中的ASP.NET MVC 2 模板建立工程后无法提交HTML代码解决方案一则

2013年05月31日 ⁄ 综合 ⁄ 共 420字 ⁄ 字号 评论关闭
Controller(HomeController):
        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

            return View();
        }
        [ValidateInput(false)]
        public ActionResult Submit(string t1)
        {
            return Content(t1);
        }

 

View(Home/Index.aspx):

   <form action="/home/submit" method="post"> 
   <input name="t1" type="text"/>
   <input type="submit" value="submit" />
   </form>

虽然设置了ValidateInput但是还是提交不了

在Web.Config中加设置以下代码即可

system.web中添加

 <httpRuntime requestValidationMode="2.0" />

抱歉!评论已关闭.