asp.net mvc 4 - How to redirect user to login page if session expire in MVC 4 Razor syntax -


On _LoginPartial.cshtml, I have entered the following code that displays the user name for the user session: < pre> & lt; P & gt; Hello, & lt; Span & gt; @ Session ["username"] & lt; / Span & gt; & Lt; / P & gt;

But here I want to add another condition that the user who ends the session has to redirect to the login page and leave the session.

How to get it.

Thank you

View this as:

 < code> @ {If (session ["user name"] = null) {& lt; P & gt; Hello, & lt; Span & gt; @ Session ["username"] & lt; / Span & gt; & Lt; / P & gt; } And {session}. Ebony (); Response.Redirect ("~ / ControllerName / ActionName"); }}    

Comments

Popular posts from this blog

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -

jasper reports - How to center align barcode using jasperreports and barcode4j -

django - CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False -