Access a value in another controller [Resolved]

Posted by Varun66 under ASP.NET MVC on 7/31/2013 | Points: 10 | Views : 1086 | Status : [Member] | Replies : 1
Hi,

I have LogIn method in Registration Controller and i need to check whether the user is registerd or not.
If the user is registered then only he can view any page otherwise he has to get logged in.
So, for this i need to access the UserName in all the controllers, how can i do this?

Thanks,
Varun.




Responses

Posted by: Kmandapalli on: 7/31/2013 [Member] Silver | Points: 50

Up
0
Down

Resolved
Hi,

You can just store it in tempData variable and access it.

TempData["UName"]=UserName;
TempData.Save();

Mark asa Answer if satisfied.......

Regards,
Shree M.

Kavya Shree Mandapalli

Varun66, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response