Search code examples
asp.net-mvchttp-headersguidbrowser-tab

Passing ID from Browser Tab/Window/Page to Server (ASP.NET MVC)


I create and safe a Browser Windows GUID in the sessionstorage on client side via javascript. So it stays alive until the tab is closed.

Now I want to pass this information on every request from this specific browser window to the server side so I can access it on any time without passing it with the model.

I use ASP.NET MVC. So there is no ViewState available if I'm right.

I thought about adding and accessing a custom field in the HTTP Header or something similar. I try to find something to accomblish that. So I need some ideas.

Thank you

(Sorry. English is not my first language)


Solution

  • Once you set the Cookies, it shall be pass with every HTTP request to the server. And in the Controller you can access Cookie via

    HttpCookie cookie = HttpContext.Request.Cookies.Get("cookie_name");