Showing posts with label postback. Show all posts
Showing posts with label postback. Show all posts

Thursday, March 29, 2012

Session var lost using InProc or StateServer mode

On my development machine my application works fine but on the
deployment server my session variable gets lost after a postback on a
webform. By doing a watch on the Session object I can see that the
SessionId is changing and the mode is StateServer. (I changed from
InProc to StateServer to try to fix the problem but it didn't have any
effect.
Details:
- Win 2k Server/IIS 5.0/.NET Framework 1.1
- I have disabled virus protection.
- The StateServer service is running.
Any ideas are greatly appreciated.
MichaelIs there an underscore character ("_") in the name of your deployment
server? There's a known bug in that case.
--
John Saunders
johnwsaundersiii at hotmail
"MG" <kloodge@.yahoo.com> wrote in message
news:8be4d6f4.0407081008.ed2152f@.posting.google.com...
> On my development machine my application works fine but on the
> deployment server my session variable gets lost after a postback on a
> webform. By doing a watch on the Session object I can see that the
> SessionId is changing and the mode is StateServer. (I changed from
> InProc to StateServer to try to fix the problem but it didn't have any
> effect.
> Details:
> - Win 2k Server/IIS 5.0/.NET Framework 1.1
> - I have disabled virus protection.
> - The StateServer service is running.
> Any ideas are greatly appreciated.
> Michael
Yes there is. Thanks for the insight !!!
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Session var lost using InProc or StateServer mode

On my development machine my application works fine but on the
deployment server my session variable gets lost after a postback on a
webform. By doing a watch on the Session object I can see that the
SessionId is changing and the mode is StateServer. (I changed from
InProc to StateServer to try to fix the problem but it didn't have any
effect.

Details:
- Win 2k Server/IIS 5.0/.NET Framework 1.1
- I have disabled virus protection.
- The StateServer service is running.

Any ideas are greatly appreciated.

MichaelIs there an underscore character ("_") in the name of your deployment
server? There's a known bug in that case.
--
John Saunders
johnwsaundersiii at hotmail

"MG" <kloodge@.yahoo.com> wrote in message
news:8be4d6f4.0407081008.ed2152f@.posting.google.co m...
> On my development machine my application works fine but on the
> deployment server my session variable gets lost after a postback on a
> webform. By doing a watch on the Session object I can see that the
> SessionId is changing and the mode is StateServer. (I changed from
> InProc to StateServer to try to fix the problem but it didn't have any
> effect.
> Details:
> - Win 2k Server/IIS 5.0/.NET Framework 1.1
> - I have disabled virus protection.
> - The StateServer service is running.
> Any ideas are greatly appreciated.
> Michael
Yes there is. Thanks for the insight !!!

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Session variable and postback question

Hello,
I have this web form where I have something like

--In pageload

If not ispostback then
session("drc") = ......
end if

and I intend to use this drc(datarowcollection) throughout a user session.

My problem is this: When a postback occurs because of say a buttonclick or radiobutton click then everything happens as I expect it to work. But when in the middle of a session I press the Refresh button of the browser (IE), then it goes into the code above i.e. page.postback = false. Because of this, I am facing a lot of difficulty. Is this something to do with the session variable. Is there another way in which I can store the datarowcollection so that I can use the same throughout the session.

_Please Help_. I would really appreciate it.

Thanks,
dotosuSo if it is NOT a postback you check for the existence of the session variable and if it does NOT exist you create what you need and then store it in there? Or you just assume that the session variable is not in there at all?
But my question is if say session.timeout = 20 and I go to this page in question and move around for 5 minutes, everything is working fine but then if I hit the Refresh button on the browser then it goes into If not page.ispostback statement. Now, it is not supposed to do this since it is not really bringing up the page for the first time, right?

Am I missing something here?

PLEASE HELP!!

Thanks, dotosu
Would anyone know why this might be happening. I would greatly appreciate help.

-dotosu
To the web server it is bringing up the page for the first time whether the session has timed out or not. This is if you do a refresh without first doing a postback.

I don't think I understand what your difficulty is here. Could you try to explain it another way and maybe I can offer more help?
I think I am sort of confused here. Please check my first post in this thread for an explanation of what my problem is. I don't think I can explain it any better but I sure need some help with this.

Now as far as I understand, we have such a sub

Sub Page_Load(...)
If Not IsPostback Then
'do something for situations when the page is first brought up
Else
' do something for situations when the page is brought up after first time
End If
End Sub
Do I not understand this correctly?

Thanks,
dotosu
Try this;

If Page.IsPostBack = False Then

'check if a session already exist
If Session("drc") = 0 Then
'set the session
Session("drc") = "yourinfo"
end if
</code
Hope this helps..
Sorry about my last oversight

Try this;


If Page.IsPostBack = False Then

'check if a session already exist
If Len(Session("drc")) = 0 Then
'set the session
Session("drc") = yourinfo
end if

Len is for the expression object (zero) as integer

Saturday, March 24, 2012

Session Variable Set to Nothing on Postback?

Why do my session variables get blown away on a post back?The user might have their cookies setting turned off.

Now, you mentioned "post-back". Are you saying that it only happens during
a post-back, or does it happen whenever a page is retrieved from the server?

"Thanks" <thanks@.thanks.com> wrote in message
news:u0%23xmho7DHA.2392@.TK2MSFTNGP11.phx.gbl...
> Why do my session variables get blown away on a post back?
Postback.. It appears to be my firewall. After you mentioned the Cookies
thing, I shut down my firewall and retried it, seems to be working.

"Peter Rilling" <peter@.nospam.rilling.net> wrote in message
news:e8vmXoo7DHA.2064@.TK2MSFTNGP11.phx.gbl...
> The user might have their cookies setting turned off.
> Now, you mentioned "post-back". Are you saying that it only happens
during
> a post-back, or does it happen whenever a page is retrieved from the
server?
> "Thanks" <thanks@.thanks.com> wrote in message
> news:u0%23xmho7DHA.2392@.TK2MSFTNGP11.phx.gbl...
> > Why do my session variables get blown away on a post back?

Tuesday, March 13, 2012

Session Variables arent retrieved during Postback

Hi I have a web page, which has a login corner. When someone logs in and clicks the "Go" button, a class called Security gathers the users details and posts it back to the same page, under a session variable called "User"

Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
'Login into the system
Dim l As New Security()
Dim Outcome As PPPL.Security.LoginOutcome

Outcome = l.DoLogin(Login.Text, Password.Text)
Select Case Outcome
Case Security.LoginOutcome.lgBADLOGIN
Case Security.LoginOutcome.lgBADPASSWORD
Case Security.LoginOutcome.lgINACTIVE
Case Security.LoginOutcome.lgLOCKED
Case Security.LoginOutcome.lgLOGGEDIN
Session("User") = l
If l.IsAdmin Then
EnableFixtureEntry(True)
Else
EnableFixtureEntry(False)
End If
Label3.Text = "You are logged in as " & l.User
End Select

End Sub


When the page postsback to itself, I need that session variable saved, so that I can access it. Trouble is when I try to retrieve it, I get a null value.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

If IsPostBack Then
'Determine if the user is logged in.
Dim l As New Security()
l = Session("User")

If Not l Is Nothing Then
pnlPredictions.Controls.Add(New LiteralControl(l.User))
End If
End If

End Sub


Problem is that when it gets to evaluating whether l Is Nothing, it always returns true. Please can someone help me?Well, I always use
Session.Add("User",1)

1 being the value or whatever you assign to it.

Put a breakpoint on your assignment. After that line executes, type
? Session("User") in your Command Window. If you get a null or nothing, then it isn't setting in the first place.
Thanks for the response.

I have done that as well, and I get the same result.

When I do a response.write on the session("User") within the Button.Click Event, it does work.

The session variable seems to reset when the Postback to the page occurs.
Could you post the entire code of the page, aspx.vb along with the aspx ?

I also wonder if your class is not properly serializing. If it doesn't serialize properly it won't be stored in viewstate. However, ASP.NET compiler would most likely error when you attempt putting Session("user") = l.

This is what I would do, use Session.add("User","LOGGEDIN")
in your login code, then in the postback, put
dim st as string = Session.Item("User")

Put a breakpoint on the line right after you grab the Session.Item("user"), and see if st = "LOGGEDIN". If it does, we know its not some weird web configuration problem.

We would then ascertain your class does not properly serialize to a string (XML).
Strange things happen when trying to reteieve complex objects from viewstate or sessions whout a proper cast. A datagrid for example must be properly casted before it can be used...

try

dim s as new Security()

s = CType(Session("User"), Security)