net MVC 重定向总结
生活随笔
收集整理的這篇文章主要介紹了
net MVC 重定向总结
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
[HttpPost]public ActionResult StudentList(string StudName, string studName, DateTime BirthDay, FormCollection form, string controller, string Action, StudentModels student){//其中StudName為aspx頁面中標簽的name屬性(StudName不區(qū)分大小寫)//其中BirthDay為頁面中標簽的name屬性(類型可自己指定【需轉(zhuǎn)換成功才可以】,這里為DateTime)同樣BirthDay不區(qū)分大小寫//其中controller,Action為路由信息(controller,Action不區(qū)分大小寫)//FormCollection包含了post回來的信息 通過form[]來取值//如果使用強類型綁定 可通過實體回傳值 這里實體為StudentModels//同樣可以使用Request.Form[] Request.QueryString[] Request[] 來取值 不過此Request非WebForm中的Request 這里的Request是RequestBase抽象類的實例 WebForm中Request是封裝類 HttpRequest的實例#region 到要經(jīng)過執(zhí)行controller里方法后 顯示出頁面。return RedirectToAction("Index");//可跳出本controllerreturn RedirectToRoute(new {controller="Home",action="Index"});//可跳出本controllerResponse.Redirect("Index");//只能使用本controller下的方法名稱。返回值為voidreturn Redirect("Index");//只能使用本controller下的方法名稱。#endregion#region 直接顯示出對應的頁面 不經(jīng)過執(zhí)行controller的方法。return View("Index");//非本方法return View("~/Views/Home/Index.aspx");//這種方法是寫全路徑#endregionreturn View();}
?
轉(zhuǎn)載于:https://www.cnblogs.com/zyj649261718/p/4975372.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的net MVC 重定向总结的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iOS9 Storyboard unwi
- 下一篇: jQuery-1.9.1源码分析系列(十