|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Session not available in Visual Studio IDEHi,
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 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 > > > 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 NewsbeitragShow 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 > > > > > >
SessionID Changes in production machine....help
Programatically set the Page Title and/or Hidden Form Field? Sharing a web-project User information in the web request ASP.NET account trying to access SQLServer Response.Redirect Error in Custom Class Running External Programs through ASP.NET Asp.net wont validate form RequiredFieldValidator ASP.NET User control browser unable to gain focus |
|||||||||||||||||||||||