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

慕村225694
TA貢獻(xiàn)1880條經(jīng)驗(yàn) 獲得超4個贊
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> 網(wǎng)頁代碼 </html> 其中IndexModel為你的Model,通過@model來指定這個頁面的對象類型為IndexModel
希望你明白~ |
- 1 回答
- 0 關(guān)注
- 405 瀏覽
添加回答
舉報
0/150
提交
取消