Tom Carter Tom Carter - 1 year ago 65
ASP.NET (C#) Question

How to save name for user in all views in ASP MVC?

I am creating a simple chat application, where user chooses his name in homepage and then, he can be sending messages in chat page. I dont know how to remember user's name without using model. Any help?

Answer Source

You could store it in Session. Assign it in a controller like Session["UserName"] = "John Doe"; Then, in the View you can access @Session["UserName"] directly, or pass it on via a ViewModel.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download