I am getting HttpContext.Current.Session is null.
Will this be a problem if we have application ho开发者_JAVA技巧sted in web farm.
Depending on the session type you are using then yes, running on a farm could cause you problems. If the load balancer or whatever you use to split requests between servers is stateless then it will just forward a request on to any old server. If the session data is stored in proc then it will only be stored on one server. If the next request goes to a different server then the session data will no longer be there.
The best ways to do this are either with more intelligent load balancing which will always forward one users requests to the same server or with another session type such as a sessionServer that is independant of the web servers and can provide consistent session state to all teh web servers.
That having been said I wouldn't expect the current session state to be null in these situations, just empty. I've recently been comign across null sessions myself in the context of launching new threads which seem to not have access to the inproc session state.
Whether any of these are problems for you its hard to say but its worth mentioning the issues of server farms to make sure you're aware. :)
精彩评论