Set authentication as true for the view of the control that performs the authentication in ASP.Net MVC?

FormsAuth. SignIn is a function which is generated when you create a new ASP. NET MVC project from Visual Studio That function simply calls FormsAuthentication.

SetAuthCookie which according to the docs, sets the authentication cookie in the response This explains why it works if you redirect (because the client will play back the cookie in the subsequent request), but not right after the call Redirecting is the right/conventional way to do this, but if you absolutely insist on checking authentication before a redirect, then you could create an IsAuthenticated flag in session state and refer to that when checking.

FormsAuth. SignIn is a function which is generated when you create a new ASP. NET MVC project from Visual Studio.

That function simply calls FormsAuthentication. SetAuthCookie, which according to the docs, sets the authentication cookie in the response. This explains why it works if you redirect (because the client will play back the cookie in the subsequent request), but not right after the call.

Redirecting is the right/conventional way to do this, but if you absolutely insist on checking authentication before a redirect, then you could create an IsAuthenticated flag in session state and refer to that when checking.

On your Controllers, you should be able to use the following to check if they're authenticated. User.Identity. IsAuthenticated; I would check to make sure that your AccountController is properly saving the Principal object as you move from page to page.

In addition to using the FormsAuth. Signin or FormsAuthentication. SetAuthCookie, you can also set the User.

Identity manually in your sign-in control when the sign-in code executes. As written above, the reason is because the FOrmsAuth. SignIn simply sets the authentication cookie to be picked up next time in the Request_OnAuthenticate event.(Which simply decodes the cookie and sets the HttpContext.

User property).

Signin or FormsAuthentication. SetAuthCookie, you can also set the User. Identity manually in your sign-in control when the sign-in code executes.

As written above, the reason is because the FOrmsAuth. SignIn simply sets the authentication cookie to be picked up next time in the Request_OnAuthenticate event. (Which simply decodes the cookie and sets the HttpContext.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions