Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using HTTPContext in web farm environment 1

Status
Not open for further replies.

LV

Programmer
Nov 1, 2000
1,184
0
0
US
I was wondering if thre is a down side (if poissible at all) in usirelying pn Context object in a web farm environment. In the current application hosted on a single web server, a pretty standard techique is used inside of the Application_AuthenticateRequest handler of an HTTP module to recreate a cusom user object implementing IPricipal on each request and attach it to HttpContext.Current. What I have concerns about, will HttpContext.Current.User.Identity.IsAuthenticated still be true after an authentication ticked and cookie were issued on web server 1 and the next request comes to web server 2?
 
The auth cookie exists on the client browser, so it will be passed to whichever server in the farm handles the request.

As far as the safety of using HttpContext, I'm not 100% positive, but I believe that while different requests during a session may be routed to different servers in the farm (complicating InProc Session and app-wide Cache), a single request will get processed in its entirity by a single server.

Since HttpContext exists on a per-request basis, it's safe to say that the IPrincipal you associate with the current context will be available when you want to use it.

All you need to do is make sure that you rebuild your custom IPrincipal on each request (or store all of the information you'd need in the auth cookie) and you should be fine.

MCP, MCTS - .NET Framework 2.0 Web Applications
 
Thanks Colin, I thought so - since the client cookie is looked up to detect authentication, it shouldn't depend on what server it goes to. Thanks for the confirmation!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top