DeveloperBarn Forums

DeveloperBarn

Programming & IT forum

HttpException - Session State not enabled.

This is a discussion on HttpException - Session State not enabled. within the .Net Development forums, part of the Programming & Scripting category; I've got a head scratcher. In my master page I have: if (Session.IsNewSession) .... In two of my pages that ...

Go Back   DeveloperBarn Forums > Programming & Scripting > .Net Development

  #1  
Old May 20th, 2008, 04:47 PM
Wolffy's Avatar
Wolfmaster
 
Join Date: Mar 2008
Real name: Wolff
Location: Peoria, IL
Posts: 779
Blog Entries: 1
Rep Power: 9
Wolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to behold
Default HttpException - Session State not enabled.

I've got a head scratcher. In my master page I have:
if (Session.IsNewSession) ....

In two of my pages that are content pages of the master, I'm now getting an HttpException -- Session state can only be used when enableSessionState is set to true... The other 10 or so content page work fine. In no place in the application do I have EnableSessioState="false".

Even after the exception is thrown, I can navigate back to one of the other working pages, and everything seems fine and dandy -- until I attempt to load one of broken pages.

I'm at a total loss as to how to shoot this bug. Anybody have a clue as to how I can determine when SessionState is being disabled?

[Edit] The offending line of code in the Page_Load event.[/edit]
__________________
Wolffy
------------------------
Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary.

Last edited by Wolffy; May 20th, 2008 at 04:56 PM.
  #2  
Old May 20th, 2008, 07:13 PM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,962
Blog Entries: 8
Rep Power: 15
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

Have you tried setting EnableSessionState="true" in the page directive of those content pages to see if it will work then?
__________________
jmurrayhead
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

If you like it here...throw us a few bones to help
support us.

Join our Folding team: DeveloperBarn Folding

  #3  
Old May 21st, 2008, 09:09 AM
Wolffy's Avatar
Wolfmaster
 
Join Date: Mar 2008
Real name: Wolff
Location: Peoria, IL
Posts: 779
Blog Entries: 1
Rep Power: 9
Wolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to behold
Default

Nope, but I'll put that idea into my bag-o-tricks today.
  #4  
Old May 21st, 2008, 09:40 AM
Wolffy's Avatar
Wolfmaster
 
Join Date: Mar 2008
Real name: Wolff
Location: Peoria, IL
Posts: 779
Blog Entries: 1
Rep Power: 9
Wolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to behold
Default

Thanks goodness for SCM's. The problem pages were ones that I had only made a minor change to; it was simple to go back to the most recent working version and my problem was solved.

We use a product from DevPartners to do an automated source code review prior to going QA. It flagged about 1200 lines of my code as problems (way more than 50% being in source files created by Visual Studio. The Designer.cs files being the worst offenders). Once of the 'suggestions' it made was to change:
Code:
<asp:HiddenField ID="hfACTIVE_CD" Value='<%# Bind("ACTIVE_CD") %>' runat="server" />
//to
<asp:HiddenField ID="hfACTIVE_CD" Value='<%# Server.HtmlEncode(Bind("ACTIVE_CD")) %>' runat="server" />
Actually it suggested Server.HTMLEncode, so I was a bit suspicious and only change it in two places rather than the 100's of places that I bind.

Since this was the only line of code I changed in this file, I removed the Server.HtmlEncode and solved the problem. Since the HtmlException was so far removed from the problem line, it took me a bit to suspect this change.
Closed Thread

  DeveloperBarn Forums > Programming & Scripting > .Net Development

Bookmarks

Thread Tools
Display Modes

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

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



All times are GMT -4. The time now is 07:07 AM.


Copyright ©2008-2010, DeveloperBarn

Content Relevant URLs by vBSEO 3.3.2