Saturday, March 24, 2012

Session variable values being lost! Why?

I am running a site using ASP.NET and have discovered that values stored in session variables are being lost when moving from one page to another. I set the values on the first page and verify that the session variables are populated. Then, on another page, where my code needs to extract the values, the session variables have values of 'nothing'.

Has anyone encountered this and, if so, do you know how to fix it?Interesting...

Are you running ASP or ASPX pages?

Do you have session state enabled on the server?

Did it used to work?
I'm running ASPX pages. Session state is enabled. It works on my PC. I have other Websites on the same server and they work. In this application, I am using the following line in the Web.config file:

<identity impersonate = "true" />

The reason I'm playing with this is that I'm trying to set-up my application so that the Website runs on the Web server, but all the files that it accesses are on another server that is not exposed to the Web.
Dumb question but has to be asked: does your client allow cookies?

I don't see think the impersonation can be causing this. I'm doing the same thing as yourself and not having any problems.
Yes, the client allows cookies. If I put all of the files that the Website uses on the same server as the Website, there is no problem. However, I get this problem when I try to access files that are on another server using impersonation.

If I remove the following line...

<identity impersonate = "true" />

...and try to access the files on another server, I get the following message: "System.IO.IOException: Logon failure: unknown user name or bad password.". If I add the above line in, it still doesn't work properly. What happens then is that a dialog pops up asking me to log-in and, if I cancel, access to the other server is denied.

If I try the following line...

<identity impersonate="true" name="domain\user" password="something" />

...as it says can be used if you lookup "impersonation" in the help files, I get the following message: "Unrecognized attribute 'name'". I think the problem must be somehow related to authentication or the way I'm trying to use impersonation. Is there some other alternative way that I can go about doing this?
You're having a great day aren't you!

Your impersonate entry looks good to me.

Does your web.config authentication look like this:

<authentication mode="Windows" />
What are you doing for IIS authentication. You using Basic or Integrated? Definitely not Anonymous right?

I'm still amazed that this authentication issue is trashing your session variables.

What is your session state mode -- "InProc"?
Yes...what a wonderful day! Well, I appreciate that you're helping me out.

The authentication mode in Web.config is "Windows".

I had the authentication mode set to Integrated and now switched it to Basic. Since the site will have SSL, I guess Basic authentication should be okay to use. Now, when I go to the site, a login dialog appears. If I type in the user name and password, I get into the site and am able to access all of the files that are on the other server. I guess there must have been some problem with me using Integrated authentication.

My next question, then, is how to bypass the login dialog that appears when the user first navigates to the site. Can I add some code somewhere or change a setting to accomplish this?

If I use the following impersonate entry...

<identity impersonate="true" name="user" password="abc" />

...I still get the "Unrecognized attribute 'name'" error. Is there somewhere specifically within the web.config file that this line is supposed to appear?

The...

<identity impersonate="true" />

...line seems to be working now, since I am able to access the files on the other server from my Web application.
did you got the answer. I am getting same problem
No, I still haven't got a reply. I'm going to try assigning permissions to the IIS account on the other server and see if that will work using anonymous authentication.
it works fine if you use netscape's browser

0 comments:

Post a Comment