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

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -