I was wondering if anyone else witnessed the same behavior?
I generate PNG image via ASP.NET code. To generate this image a user ID must be stored in a persistent cookie. Before I begin generating the image I begin reading the cookie as such:
HttpCookie cookie = Request.Cookies["MyCookieName"];
if (cookie != null)
{
//Read cookie value
}
It works fine except the situation when I load my page in IE and then try to either print that page or generate a preview. In that case the 'cookie' variable in my code becomes null and the whole image logic fails. Note that the HTML page itself (that also
uses the same cookie) renders just fine.
Also note that if I do the same in Chrome or Firefox the image is printed/previewed without a problem.
I stopped using IE a long time ago, but I hear that some people may still be using it. So, my first question, is it worth bothering to fix it for IE? And if yes, any idea how to make it work there?
Do you have any plugins installed for IE? If so, try by disabling them. To me, it seems like this a problem specific to your browser only. If you can, please check this in another machine's IE.
Then to test what I see, load it up in IE (through ASP.NET Development Server that comes with VS2010.) Then click on Set Cookie, then Test Cookie. You should see the yellow image with the words that cookie is set. Then go to Print Preview (in IE menu.) When
print preview is loaded up, in my case I get an empty yellow rectange, although the text words that the cookie is set are there. This happens only in IE.
Now if you repeat the same in Chrome or FF, it will work.
Hi, I tested your codes on my computer with IE9 and found the text words showed up with IE9 Print Preview. This issue can occur due to your IE settings, please reset your IE settings and check the result again.
dc2000
Member
68 Points
104 Posts
Cookies not available in IE when generating preview of the web page
Apr 28, 2012 07:23 AM|LINK
I was wondering if anyone else witnessed the same behavior?
I generate PNG image via ASP.NET code. To generate this image a user ID must be stored in a persistent cookie. Before I begin generating the image I begin reading the cookie as such:
HttpCookie cookie = Request.Cookies["MyCookieName"]; if (cookie != null) { //Read cookie value }It works fine except the situation when I load my page in IE and then try to either print that page or generate a preview. In that case the 'cookie' variable in my code becomes null and the whole image logic fails. Note that the HTML page itself (that also uses the same cookie) renders just fine.
Also note that if I do the same in Chrome or Firefox the image is printed/previewed without a problem.
I stopped using IE a long time ago, but I hear that some people may still be using it. So, my first question, is it worth bothering to fix it for IE? And if yes, any idea how to make it work there?
poojajoon
Member
228 Points
52 Posts
Re: Cookies not available in IE when generating preview of the web page
Apr 28, 2012 07:51 AM|LINK
Hey
I have also tried using Cookies in IE and used the code as follows
if (Request.Cookies["id"] == null)
Response.Redirect("~/index.aspx");
and it is working fine with my page.
Please give complete code so that i can check if there is some other problem with the code.
dc2000
Member
68 Points
104 Posts
Re: Cookies not available in IE when generating preview of the web page
Apr 28, 2012 08:19 AM|LINK
Note, that the issue happens when I generate an image and not just HTML content.
ramiramilu
All-Star
95503 Points
14106 Posts
Re: Cookies not available in IE when generating preview of the web page
Apr 28, 2012 09:18 AM|LINK
it seems like your logic is problem...IE never got any problems with Cookies...so debug your code and see how cookie values changes....
or may be some of your IE settings are causing problem..check them...
Thanks,
JumpStart
Ruchira
All-Star
43066 Points
7044 Posts
MVP
Re: Cookies not available in IE when generating preview of the web page
Apr 28, 2012 11:26 AM|LINK
Hello,
Do you have any plugins installed for IE? If so, try by disabling them. To me, it seems like this a problem specific to your browser only. If you can, please check this in another machine's IE.
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.dc2000
Member
68 Points
104 Posts
Re: Cookies not available in IE when generating preview of the web page
Apr 28, 2012 10:10 PM|LINK
I compiled a test project to illustrate the issue:
http://dl.dropbox.com/u/36312383/WebAppTestImgPreviewCookie.zip
This is a web app project so you'll have to build it with VS2010.
Then to test what I see, load it up in IE (through ASP.NET Development Server that comes with VS2010.) Then click on Set Cookie, then Test Cookie. You should see the yellow image with the words that cookie is set. Then go to Print Preview (in IE menu.) When print preview is loaded up, in my case I get an empty yellow rectange, although the text words that the cookie is set are there. This happens only in IE.
Now if you repeat the same in Chrome or FF, it will work.
dc2000
Member
68 Points
104 Posts
Re: Cookies not available in IE when generating preview of the web page
May 02, 2012 08:00 PM|LINK
So, did anyone have a chance to look at it???
Allen Li - M...
Star
10411 Points
1196 Posts
Re: Cookies not available in IE when generating preview of the web page
May 03, 2012 08:40 AM|LINK
Hi, I tested your codes on my computer with IE9 and found the text words showed up with IE9 Print Preview. This issue can occur due to your IE settings, please reset your IE settings and check the result again.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework
dc2000
Member
68 Points
104 Posts
Re: Cookies not available in IE when generating preview of the web page
May 03, 2012 08:51 AM|LINK
Thank you, Allen. I'll do more tests on my end.