问题
I have an asp.net application that uses ajax. I want to be able to pass data from one page to another so I store what I want in a session variable and redirect the response to the destination page where i retrieve what i want for further processing. I use:
Response.Redirect(path, false)
Everything works fine until I try to publish to my staging iis7 server. My session variable always returns empty. But if I try to navigate to the page from within the iis server itself (via right click on the page in iis and clicking explore) it works well and the session variable value is retained. It only does it when I am accessing the iis application from my browser. Everything else works well like loadin pages, controls, the redirect. It is only that the session variables result to empty.
回答1:
This can happen when the application pool is misconfigured, like for example if you set the number of worker processes to more than one.
Another common cause of this issue is when the server name contains underscores (e.g. DEV_TEST). Underscores aren't allowed as host names, and could interfere with the ability to set cookies.
来源:https://stackoverflow.com/questions/8094840/session-variable-empty-in-iis7-application