Home All Groups Group Topic Archive Search About

Session not available in Visual Studio IDE

Author
13 May 2005 1:31 PM
Axel Dahmen
Hi,

after I've added a property to my web page I can't open it in Visual Studio
Designer anymore. I get the error message "File couldn't be opened in Web
Forms Designer. [...] enablesessionstate page directive required to use
Session object."

I see that Visual Studio Web Forms Designer seems to execute any Property
code when opening the page. But I don't want it to.

How can I check if my page is in design mode so that I can skip any relevant
code during working in Designer?

TIA,
Axel Dahmen

Author
13 May 2005 2:04 PM
Cowboy (Gregory A. Beamer) - MVP
Add property? To ASPX page in a code section or in the CodeBehind? I have
added properties in CodeBehind without any problems, but have not tried in
the ASPX itself, so that is the only thing I know of to look at right now. If
you do not get a good direction, post some code so someone can attempt to
repro your steps.


---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************


Show quoteHide quote
"Axel Dahmen" wrote:

> Hi,
>
> after I've added a property to my web page I can't open it in Visual Studio
> Designer anymore. I get the error message "File couldn't be opened in Web
> Forms Designer. [...] enablesessionstate page directive required to use
> Session object."
>
> I see that Visual Studio Web Forms Designer seems to execute any Property
> code when opening the page. But I don't want it to.
>
> How can I check if my page is in design mode so that I can skip any relevant
> code during working in Designer?
>
> TIA,
> Axel Dahmen
>
>
>
Are all your drivers up to date? click for free checkup

Author
15 May 2005 12:27 PM
Axel Dahmen
Thanks for trying to help me.

I've created a new Page base class derived from Page, MyPage. Now I'm
deriving all my web pages from MyPage instead of Page. This works very well
so far.

Here's the code I've added to MyPage.cs:

public HostApp CurHostApp

{

get {return (HostApp)Session["HostApp"];}

set {if (value==null || value.Count==0) Session.Remove("HostApp");

else Session["HostApp"]=value;}

}


Due to the Session object referenced in this property, VS Web Form Designer
is not able to show me a design view anymore. So I need to know how to tell
if my code is executed from within VS Designer, so that I can comment out
the code like:

{

get {return VisualStudio.ViewedFromWithinDesigner ? null :
(HostApp)Session["HostApp"];}

}



Axel


---------------------
"Cowboy (Gregory A. Beamer) - MVP" <NoSpamMgbworld@comcast.netNoSpamM>
schrieb im Newsbeitrag
Show quoteHide quote
news:94D7322F-5FD1-44C8-B3BE-818202E69DF5@microsoft.com...
> Add property? To ASPX page in a code section or in the CodeBehind? I have
> added properties in CodeBehind without any problems, but have not tried in
> the ASPX itself, so that is the only thing I know of to look at right now.
If
> you do not get a good direction, post some code so someone can attempt to
> repro your steps.
>
>
> ---
>
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> ***************************
> Think Outside the Box!
> ***************************
>
>
> "Axel Dahmen" wrote:
>
> > Hi,
> >
> > after I've added a property to my web page I can't open it in Visual
Studio
> > Designer anymore. I get the error message "File couldn't be opened in
Web
> > Forms Designer. [...] enablesessionstate page directive required to use
> > Session object."
> >
> > I see that Visual Studio Web Forms Designer seems to execute any
Property
> > code when opening the page. But I don't want it to.
> >
> > How can I check if my page is in design mode so that I can skip any
relevant
> > code during working in Designer?
> >
> > TIA,
> > Axel Dahmen
> >
> >
> >

Bookmark and Share

Post Thread options