Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Missing Viewstate

 
Thread Tools Search this Thread
Old 11-04-2009, 04:49 PM   #1
Default Missing Viewstate


Hi all,

I hope someone understands this better than I do. I have an ASP.NET
app using a MasterPage (which I actually created in DreamWeaver then
copied the HTML to the MasterPage). So far so good.

The master page has a fancy nav menu (a SpryMenu) at the top - this
does not cause post backs - just a fancy collection of hyperlinks.

I want to track the currently logged in user in the View State. I do
this thus:

If (correct password)
{
Session["USERID"] = userid;
Server.Transfer("MyAccount.aspx");
}

And in all pages do something like

if (Session["USERID"] == null)
Response.Redirect("Login.aspx");

At this point I am on MyAccount.aspx via a Server.Transfer. I can
choose any page in my fancy nav menu, which are just hyperlinks, and
in the respective Page_Load I can get the userid from the session.
But only the once. That page will load fine and display user
information from the database etc. But if I choose another page from
the nav menu - even the same page, the Session variables have gone.
The Session.SessionID is the same but Session.Count is 0.

Can anyone shed any light on what may be happening behind the scenes -
I am perplexed.

Thanks

Kev


Kev
  Reply With Quote
Old 11-04-2009, 05:20 PM   #2
Kev
 
Posts: n/a
Default Re: Missing Viewstate
Hi again,

further investigation leads me to believe that something in the eBay
API is causing the vewstate to get reset. Which is odd as the eBay
API should not user the viewstate - what if it was a desktop client
application? However, it does make a web service call.

If I remove the eBay API SOAP call the problem I previously described
vanishes and the viewstate remains intact across pages in the nav bar
despite none of them doing postbacks. Is this correct or just luck?

Should making a web service call confuse the view state?

I believe this is still the correct place for this discussion but if
not will accept any guidance to the correct place.

Thanks all.


On 4 Nov, 16:49, Kev <k.mel...@theiet.org> wrote:
> Hi all,
>
> I hope someone understands this better than I do. *I have an ASP.NET
> app using a MasterPage (which I actually created in DreamWeaver then
> copied the HTML to the MasterPage). *So far so good.
>
> The master page has a fancy nav menu (a SpryMenu) at the top - this
> does not cause post backs - just a fancy collection of hyperlinks.
>
> I want to track the currently logged in user in the View State. *I do
> this thus:
>
> If (correct password)
> {
> * * Session["USERID"] = userid;
> * * Server.Transfer("MyAccount.aspx");
>
> }
>
> And in all pages do something like
>
> *if (Session["USERID"] == null)
> * * * * * * * * * * Response.Redirect("Login.aspx");
>
> At this point I am on MyAccount.aspx via a Server.Transfer. *I can
> choose any page in my fancy nav menu, which are just hyperlinks, and
> in the respective Page_Load I can get the userid from the session.
> But only the once. *That page will load fine and display user
> information from the database etc. *But if I choose another page from
> the nav menu - even the same page, the Session variables have gone.
> The Session.SessionID is the same but Session.Count is 0.
>
> Can anyone shed any light on what may be happening behind the scenes -
> I am perplexed.
>
> Thanks
>
> Kev




Kev
  Reply With Quote
Old 11-04-2009, 05:23 PM   #3
Scott M.
 
Posts: n/a
Default Re: Missing Viewstate

"Kev" <> wrote in message
news:77fa22e3-c7ba-4a9e-ac02-...
> Hi all,
>
> I hope someone understands this better than I do. I have an ASP.NET
> app using a MasterPage (which I actually created in DreamWeaver then
> copied the HTML to the MasterPage). So far so good.
>
> The master page has a fancy nav menu (a SpryMenu) at the top - this
> does not cause post backs - just a fancy collection of hyperlinks.
>
> I want to track the currently logged in user in the View State. I do
> this thus:
>
> If (correct password)
> {
> Session["USERID"] = userid;
> Server.Transfer("MyAccount.aspx");
> }
>
> And in all pages do something like
>
> if (Session["USERID"] == null)
> Response.Redirect("Login.aspx");
>
> At this point I am on MyAccount.aspx via a Server.Transfer. I can
> choose any page in my fancy nav menu, which are just hyperlinks, and
> in the respective Page_Load I can get the userid from the session.
> But only the once. That page will load fine and display user
> information from the database etc. But if I choose another page from
> the nav menu - even the same page, the Session variables have gone.
> The Session.SessionID is the same but Session.Count is 0.
>
> Can anyone shed any light on what may be happening behind the scenes -
> I am perplexed.
>
> Thanks
>
> Kev


First, I'd ensure that sessions are enabled and configured correctly in IIS.

Second, you need to check your browser's cookie setting to ensure that
session cookies are allowed.

Third, what does your scenario have to do with ViewState as you are not
using it in the description you gave us?

-Scott




Scott M.
  Reply With Quote
Old 11-04-2009, 05:27 PM   #4
David
 
Posts: n/a
Default Re: Missing Viewstate
This is not viewstate, but session.

From what I remember from classic asp, the page has to be delivered to the
browser in order that the session is set up correctly. Sessions use cookies
to track them.

Here, you are setting the session, then redirecting immediately (on the
server, so the page is not even being sent to the client), hence the session
cookie is not being dropped to the client.

Instead, why not use the login tools from .NET and use the
RedirectFromLoginPage(username, false) (but you need the ReturnUrl in your
querystring) or the SetAuthCookie(username, false)...

This will set up your authentication and in each page you can then check if
the user is authenticated, User.Identity.IsAuthenticated


--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available


"Kev" <> wrote in message
news:77fa22e3-c7ba-4a9e-ac02-...
> Hi all,
>
> I hope someone understands this better than I do. I have an ASP.NET
> app using a MasterPage (which I actually created in DreamWeaver then
> copied the HTML to the MasterPage). So far so good.
>
> The master page has a fancy nav menu (a SpryMenu) at the top - this
> does not cause post backs - just a fancy collection of hyperlinks.
>
> I want to track the currently logged in user in the View State. I do
> this thus:
>
> If (correct password)
> {
> Session["USERID"] = userid;
> Server.Transfer("MyAccount.aspx");
> }
>
> And in all pages do something like
>
> if (Session["USERID"] == null)
> Response.Redirect("Login.aspx");
>
> At this point I am on MyAccount.aspx via a Server.Transfer. I can
> choose any page in my fancy nav menu, which are just hyperlinks, and
> in the respective Page_Load I can get the userid from the session.
> But only the once. That page will load fine and display user
> information from the database etc. But if I choose another page from
> the nav menu - even the same page, the Session variables have gone.
> The Session.SessionID is the same but Session.Count is 0.
>
> Can anyone shed any light on what may be happening behind the scenes -
> I am perplexed.
>
> Thanks
>
> Kev





David
  Reply With Quote
Old 11-04-2009, 05:28 PM   #5
Kev
 
Posts: n/a
Default Re: Missing Viewstate
On 4 Nov, 17:23, "Scott M." <s-...@nospam.nospam> wrote:
> "Kev" <k.mel...@theiet.org> wrote in message
>
> news:77fa22e3-c7ba-4a9e-ac02-...
>
>
>
>
>
> > Hi all,

>
> > I hope someone understands this better than I do. *I have an ASP.NET
> > app using a MasterPage (which I actually created in DreamWeaver then
> > copied the HTML to the MasterPage). *So far so good.

>
> > The master page has a fancy nav menu (a SpryMenu) at the top - this
> > does not cause post backs - just a fancy collection of hyperlinks.

>
> > I want to track the currently logged in user in the View State. *I do
> > this thus:

>
> > If (correct password)
> > {
> > * *Session["USERID"] = userid;
> > * *Server.Transfer("MyAccount.aspx");
> > }

>
> > And in all pages do something like

>
> > if (Session["USERID"] == null)
> > * * * * * * * * * *Response.Redirect("Login.aspx");

>
> > At this point I am on MyAccount.aspx via a Server.Transfer. *I can
> > choose any page in my fancy nav menu, which are just hyperlinks, and
> > in the respective Page_Load I can get the userid from the session.
> > But only the once. *That page will load fine and display user
> > information from the database etc. *But if I choose another page from
> > the nav menu - even the same page, the Session variables have gone.
> > The Session.SessionID is the same but Session.Count is 0.

>
> > Can anyone shed any light on what may be happening behind the scenes -
> > I am perplexed.

>
> > Thanks

>
> > Kev

>
> First, I'd ensure that sessions are enabled and configured correctly in IIS.
>
> Second, you need to check your browser's cookie setting to ensure that
> session cookies are allowed.
>
> Third, what does your scenario have to do with ViewState as you are not
> using it in the description you gave us?
>
> -Scott- Hide quoted text -
>
> - Show quoted text -


Thanks Scott - you just beat me to it.

Forget all mention of ViewState. I am not using the ViewState at
all. I am primarily interested in the Session state.

I have checked IIS. It is configured to use in process session and
uses cookies with a 20 minute time out.

The browser is correctly observing cookies.

When I run through the debugger, the session id remains constant at my
break points so I am sure this is fine.

I execute the web service and all the session elements are there. But
when I hit the same break point (first line in Page_Load) they have
gone and Session.Count is a red zero. Becuase of the web service
call, it is getting reset.

The question is, what is the web service call doing to cause the
session to get reset? I have the web service source and it doesn't
appear to be doing anything - is it an IIS thing?

Thanks again

Kevin


Kev
  Reply With Quote
Old 11-04-2009, 05:32 PM   #6
Scott M.
 
Posts: n/a
Default Re: Missing Viewstate

"Kev" <> wrote in message
news:0fe7bd94-b0fe-4595-a544-...
Hi again,

further investigation leads me to believe that something in the eBay
API is causing the vewstate to get reset. Which is odd as the eBay
API should not user the viewstate - what if it was a desktop client
application? However, it does make a web service call.

If I remove the eBay API SOAP call the problem I previously described
vanishes and the viewstate remains intact across pages in the nav bar
despite none of them doing postbacks. Is this correct or just luck?

Should making a web service call confuse the view state?

I believe this is still the correct place for this discussion but if
not will accept any guidance to the correct place.

Thanks all.


On 4 Nov, 16:49, Kev <k.mel...@theiet.org> wrote:
> Hi all,
>
> I hope someone understands this better than I do. I have an ASP.NET
> app using a MasterPage (which I actually created in DreamWeaver then
> copied the HTML to the MasterPage). So far so good.
>
> The master page has a fancy nav menu (a SpryMenu) at the top - this
> does not cause post backs - just a fancy collection of hyperlinks.
>
> I want to track the currently logged in user in the View State. I do
> this thus:
>
> If (correct password)
> {
> Session["USERID"] = userid;
> Server.Transfer("MyAccount.aspx");
>
> }
>
> And in all pages do something like
>
> if (Session["USERID"] == null)
> Response.Redirect("Login.aspx");
>
> At this point I am on MyAccount.aspx via a Server.Transfer. I can
> choose any page in my fancy nav menu, which are just hyperlinks, and
> in the respective Page_Load I can get the userid from the session.
> But only the once. That page will load fine and display user
> information from the database etc. But if I choose another page from
> the nav menu - even the same page, the Session variables have gone.
> The Session.SessionID is the same but Session.Count is 0.
>
> Can anyone shed any light on what may be happening behind the scenes -
> I am perplexed.
>
> Thanks
>
> Kev


You didn't mention anything about eBay in your original post, which
certainly can contribute to the issue. You'll need to be clearer as to what
eBay's systems have to do with your web application and how eBay affects
your login. eBay has a published set of API's for developers wanting to
automate thier functions.

But, as I said in my last message, you haven't told or shown us anything
about your site that relates to ViewState, you've discussed the problem you
are having with Session state, which is entirely different than ViewState.

-Scott




Scott M.
  Reply With Quote
Old 11-04-2009, 05:41 PM   #7
Kev
 
Posts: n/a
Default Re: Missing Viewstate
Hi Scott,

you are corrrect. My apologies. I didn't believe eBay APIs were at
fault when first posting. But I admit being new to ASP.NET I was
confusing the ViewState session state issue.

My issue is that a call the eBay API is resetting the Session state.

Why I do not know as the eBay API should not know I am using a
SessionState as I could be writing a WinForms app. So I am wondering
if a .NET call the API makes is upsetting the .NET framework some how.

Am still investigating but any thoughts appreciated.

Cheers


Kev
  Reply With Quote
Old 11-04-2009, 05:52 PM   #8
Kev
 
Posts: n/a
Default Re: Missing Viewstate
Ok - I now know which the offending line of code is. It is in the
eBay API and its

LogMessage(url, MessageType.Information,
MessageSeverity.Informational);

Looks pretty innocent, and what it does by stepping through it appears
innocent too. Doesn't even look at the Session state. But something
it is doing is sending ASP.NET into a spin. Not sure if this is
correct place for this discussion but if anyone has any similar
experiences please do feedback one way or another.

Thanks again - particularly to Scott.


Kev
  Reply With Quote
Old 11-04-2009, 05:54 PM   #9
Scott M.
 
Posts: n/a
Default Re: Missing Viewstate
It would be best if you could post your complete code, so we can see exactly
what you are doing.

But, I do believe that David is correct, that using Server.Transfer is not
transfering your session state. It's working the first time because of the
initial session variable you set, but after that it's being lost. Do you
have a specific reason for using Transfer vs. Redirect, which would solve
the problem.

- Scott




Scott M.
  Reply With Quote
Old 11-04-2009, 06:03 PM   #10
Kev
 
Posts: n/a
Default Re: Missing Viewstate
Apologies - I never even saw Davids reply.

David, your comments make sense and I will look into using a different
method of UserAuthentication.

However, the current situation is that a call to the eBay APIs is
causing the session to get reset? What would cause this?

I sm still trying to identify the exact line of code causing this.

Kevin.


Kev
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linksys tech support live chat transcript - enjoy!!!! jim Wireless Networking 2 07-01-2008 05:19 AM
System Restore -to start with...... =?Utf-8?B?SGFycnkgS2VvZ2g=?= Windows 64bit 3 12-01-2005 08:58 AM
PowerPost2000 and reposting missing segments. English Patient Computer Support 6 09-15-2004 11:49 PM
Invalid Backweb Mike Doherty Computer Support 3 01-30-2004 08:02 PM
Re: Pentagon 9/11: The Missing Wings Baron Maximillian von Schtuldeworfshiseundurheimhoppen Computer Support 0 10-27-2003 06:09 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46