asp.net MVC中,某個頁面中的Model是怎么指定的?
1 回答

Smart貓小萌
TA貢獻1911條經驗 獲得超7個贊
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | Controller代碼如下:
public class HomeController : Controller { public ActionResult Index() { return View(); } [HttpPost] public ActionResult Index(IndexModel model) { return View(model); } }
視圖,位于~/Views/Home/Index.cshtml,代碼 @model IndexModel <html> </html> 其中IndexModel為你的Model,通過@model來指定這個頁面的對象類型為IndexModel
希望你明白~ |
- 1 回答
- 0 關注
- 393 瀏覽
添加回答
舉報
0/150
提交
取消