預設是get提交,如果是post提交需要在控制器ActionResult上加:[AcceptVerbs(HttpVerbs.Post)] 舉例: 在HelpController中,會定義如下的Action: [AcceptVerbs(HttpVerbs.Post)] public ActionRes ...
預設是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>