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> 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: & lt; P & gt; Hello, & lt; Span & gt; @ Session ["username"] & lt; / Span & gt; & Lt; / P & gt;
< 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
Post a Comment