session - MVC 4 code file (.cs) redirect to an action -
i have created .cs file checking session values.
using session below
httpcontext.current.session["usrprof"]
it written in simple .cs file.
can use if in controller can use in normal .cs file
can use redirect action if don't in session
if (httpcontext.current.session["usrprof"] == null) //redirect action.
you can use redirect response object
if (httpcontext.current.session["usrprof"] == null) { httpcontext.response.redirect("/controller/action"); }
hope helps
Comments
Post a Comment