【c# – MVC中的必需值为空字符串,但modelstate仍然有效】教程文章相关的互联网学习教程文章

c# – ‘Models.LoginViewModel’是一种类型,在给定的上下文中无效【代码】

我的代码是:@sample.Models.LoginViewModel @{string user = Session["users"].ToString(); } @{ViewBag.Title = "Home Page"; }我收到错误:‘@sample.Models.LoginViewModel’ is a type, which is not valid in the given context. 请提出任何解决我的问题的想法.解决方法:改变代码@sample.Models.LoginViewModel如@model sample.Models.LoginViewModel即是@model sample.Models.LoginViewModel@{if(Session["users"] != nul...