开发者

PAGE.USER missing in ASP.NET MVC?

开发者 https://www.devze.com 2022-12-18 08:26 出处:网络
I think Page开发者_如何学JAVA.User.Identity.IsAuthenticated is available in ASP.NET MVC, because I see other people talking about using it.

I think Page开发者_如何学JAVA.User.Identity.IsAuthenticated is available in ASP.NET MVC, because I see other people talking about using it.

However, when I type Page., the intellisense gives me only these 3 options :

CreateHtmlTextWriterFromType Equals ReferenceEquals

What do you think is going on?

EDIT: If I do Page page = new Page(), then page.User works. Is it really needed?


You can access it in Controller :HttpContext.User.Identity.IsAuthenticated You can acces it in view like this :<% if(User.Identity.IsAuthenticated){} %> Hope this helps.


Page is a Webforms object, not much help in MVC. You can access the authenticated user from the HTTP Context, something like httpcontext.user.identity

0

精彩评论

暂无评论...
验证码 换一张
取 消