Cookies Not Written When Debugging?

J

Johnnie Norsworthy

I am trying to debug a C# ASP.NET application in VS.NET. I have added a
text box to my form for storing a user signature which I am trying to
persist using cookies.

In my Page_Load() I have added the following:
try
{
Signature.Text = Request.Cookies["Signature"].Value;
}
catch
{
Signature.Text = "";
}

It seems that this cookie is always null, even though I trace through my
code as follows that is executed on a button press:
Response.Cookies["Signature"].Value = Signature.Text;
Response.Cookies["Signature"].Expires = DateTime.Now.AddMonths(6);

and the cookie appears to be written with no errors. But I cannot locate
the cookie file under "Documents and Settings\Username\Cookies".
Is there a cookie writing restriction when debugging in the VS.NET IDE?
Thanks for any help. My code seems simple enough, but please let me know if
something is wrong there.

My Web.config has cookieless="false", if that matters.

-Johnnie
 
W

William F. Robertson, Jr.

Without seeing all your code, let me say this.

Your Signature.Text assignment. Is that protected by a if (
!Page.IsPostBack ). If it is not then you are setting the .Text property of
that control to String.Empty on postback, so when the button click executes
it will be placing in a String.Empty.

just a thought.

If you want post some more code, but no, cookies have nothing to do with
being in the IDE debugger.

Now what is really strange is there should always be a cookie with the
session id. Are you sure you are looking for the correct cookie name?

HTH,

bill
 
J

Johnnie Norsworthy

William F. Robertson said:
Without seeing all your code, let me say this.

Your Signature.Text assignment. Is that protected by a if (
!Page.IsPostBack ). If it is not then you are setting the .Text property of
that control to String.Empty on postback, so when the button click executes
it will be placing in a String.Empty.

just a thought.

Yes, right before the assignment in my Page_Load code I have:
if (IsPostBack) return;
This prevents all of initialization code, including the Signature.Text
assignment from running again. Tracing the code proves this is the case.
Now what is really strange is there should always be a cookie with the
session id. Are you sure you are looking for the correct cookie name?

I looked under every Documents & Settings user listed and no new cookies
ever appear. That is under, "Default User","MyUserLogin","MyComputerID".
What should it be named? I sorted all of the cookies by date to see the
newest and nothing new appears. I noticed under D&S/MyUserLogin/Cookies/
that the Index.dat file is touched (date changed) when I run my app. But I
never see any new cookies there.
Where should it be located?

It *could* be an issue with Norton Internet Security, but other cookies have
been saved fine this week, just not from my application. I disabled NIS,
and that did not help.

I'm sure there is a simple answer to this, but I am a newbie and the books I
have make it look so simplistic I can't see the problem.

Thanks,
Johnnie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top