2014-1219

用如下方法获取UserId报空引用异常

public class BaseController : Controller
{
    protected SiteContext db = new SiteContext();
    protected Guid userId;
    public BaseController()
    {
        userId = Guid.Parse(User.Identity.GetUserId());
    }
}

由于Controller未初始化完成,User为空,重写初始化方法,在初始化(ba 阅读全文>>

标签: MVC5 Controller User Null 阅读:7829