Pergunta

I have a gridview that gets Hyperlink Values from my table which i also append to the NavigateUrl of the hyperlink like so

<asp:HyperLink ID="LinkSection" runat="server" Text='<%# Eval("SECTION") %>' NavigateUrl='<%# "http://localhost:50686/" + (string)Eval("SECTION") + ".aspx"%>'>

Everything seemed to work great while debugging the horror started once I went to deploy the website. I noticed IIS uses INPROC for Sessions not sure what Visual Studios uses while debugging but that works great.

Once I go into my webconfig file and manually set Session Variables to use INPROC

<sessionState mode="InProc"
                  cookieless="true"
                  regenerateExpiredSessionId="true"
                  timeout="30" />

My application no longer works seems like I am losing my Session Value once I click the hyperlink. So I added some logic to redirect back to my login page if the Session Value is null and the funny part is once I click a link and it sends me back to the login page, if i was to log back in it works sometimes.

I am setting my session value like so

Session["LoggedInUser"] = txtEmail.Text;

And retrieve it

 cmd.Parameters["@EMAILACCT"].Value = Session["LoggedInUser"];

I am not deploying this to any server farm so would like to stick with the best performance method of session which I read is INPROC if possible.

Foi útil?

Solução

Looks like while playing with sessionstate mode you have overlooked cookieless option. With mode=Inproc and cookieless=true, asp.net uses url to store session id. If you use absolute url, asp.net can't append the sessionid. Work around is to convert the url to relative url like this:

NavigateUrl = Response.ApplyAppPathModifier(yoururl);

Here is a discussion, you may find it helpful.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top