asp.net mvc4 Html.BeginForm表单提交

默认是get提交,如果是post提交需要在控制器ActionResult上加:[AcceptVerbs(HttpVerbs.Post)]

举例:

在HelpController中,会定义如下的Action:

[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Search() {
          string searchTit = Request["searchTit"];
            return RedirectToAction("Index");
        }

在View中,如下:

<div>
        @using(Html.BeginForm("Search","Help")){ 
        <input id="searchTit" name="searchTit" type="text" placeholder="请输入要填写的内容" class="input_text_help" />
        <div>
            <input type="submit" id="submit" name="submit" value="submit" />
        </div>
       }
    </div>

posted @ 2016-06-22 16:17  haishu  阅读(964)  评论(1编辑  收藏  举报