[Lesson 4:] Understanding Web Application State

Please install Silverlight or click download to watch video locally.

In this lesson, you will see how to maintain state in ASP.NET, including the various objects you can use to store information for your ASP.NET 2.0 applications.

Duration: 40 minutes, 42 seconds

Date: 28 November 2005

Watch    VB Video    C# Video   |   Download    VB Video    C# Video   |   VB Code    C# Code

Video downloads: WMV   WMV  |  Zune   Zune  |  iPod   iPod  |  PSP   PSP  |  MPEG-4   MPEG-4  |  3GP   3GP

Audio downloads: AAC   AAC  |  WMA   WMA  |  MPEG-4   MPEG-4  |  MPEG-3   MPEG-3  |  MPEG-2   MPEG-2

Comments : 58

Leave a Comment

charlescva : On March 25, 2008 10:57 AM said:

i recieve the following error when using C# to follow this tutorial.

App_Code.cy2wsazk.0.cs

// <auto-generated>

//     This code was generated by a tool.

//     Runtime Version:2.0.50727.1433

//

//     Changes to this file may cause incorrect behavior and will be lost if

//     the code is regenerated.

// </auto-generated>

...

   public virtual string MyNewProperty {

       get {

           return ((string)(this.GetPropertyValue("MyNewProperty")));

       }

       set {

           ****this.SetPropertyValue("MyNewProperty", value);**** Unable to connect to SQL Server database.

       }

   }

I do not understand.   I started a new webpage and followed the directions explicitly.  i do not understand why i am getting this error.

prophetpius : On March 27, 2008 1:38 PM said:

"Unable to connect to SQL Server Database" Check to confirm that the sql service is runnig, also confirm that u specified the correct database name in ur connection string

prophetpius : On March 27, 2008 1:39 PM said:

Please how were u able to download this video??????????????

when i click the download link it does not respond

wleearmitage : On March 27, 2008 11:52 PM said:

I am following along with the VB version and am doing exaclty what is being done in the video. When I get to about 26 minutes we add the following lines to the web.config file:

    <properties>

<add name="MyNewProperty" allowAnonymous="true"/>

    </properties>

</profile>

When I added this code and ran the project, I get an error saying it cannot find the SQL Server. Up to this point the project has been running fine. And no use of a SQL server has been used.

Any Help?

Lee Armitage

romulusc : On April 02, 2008 7:45 AM said:

Hi,

Check out this link: weblogs.asp.net/.../423703.aspx

romulusc : On April 02, 2008 7:50 AM said:
SATAGE : On April 15, 2008 10:30 AM said:

nice to me i try to see

Yankee : On April 17, 2008 4:51 PM said:

finally a full screen option online. so no download :D

Manmadhan : On April 17, 2008 7:34 PM said:

Can be pretty slow in rushing all page objects.

Soha.Jawabreh : On April 25, 2008 1:09 PM said:

useful video but i felt that I’m lost coz of the too many objects are being used :(

turner03 : On May 09, 2008 3:00 PM said:

I followed the links... and when i got to Step 3, i got confused... does anyone know where you open this?

turner03 : On May 13, 2008 11:10 AM said:

got it now!

imarash : On May 16, 2008 12:34 PM said:

So which one is better to use for websites with higher traffic?

dragby : On June 03, 2008 5:51 AM said:

Hi Arash,

As I understand it after watching the video, if a web site experiences heavy traffic, using Viewstate consumes bandwidth whearas using the session object consumes server memory. The alternative is to create a profile object in the web.config file which stores the information in a database, xml-file or wherever you designate.

If anyone gets an "Unable to connect to SQL Server Database" problem when referencing the profile object, then it could be because they did what I did. I deselected installing the "SQL Server Enterprise Edition (or whatever it's called) when installing Visual Web Developer. (I did so because I already had SQL Server installed on my machine.) I went to the download site and installed it. At first it didn't work, but later on (I guess after a restart of VWD) I no longer have this problem.

dragby : On June 03, 2008 7:39 AM said:

... actually I do still get an SQL error, but this seems to be due to a time out.

If i run the application a second time, so things load faster, then it works ok.

AdamBies : On June 17, 2008 9:29 AM said:

At 31:46 in the video, the Label does not populate with the value from the URL string when he runs the page application.  I sat here trying to figure it out myself having paused the video before I realized it did not work for the guy in the video either.

How come the guy just moves on to the next topic even though the code obviously didn't work when he ran the page without trying to fix it or explain why it didn't work for him either?

AdamBies : On June 17, 2008 9:53 AM said:

Nevermind.  I see that he re-traces the steps and see why it wasn't working.  Would have been nice to edit that one part out to avoid confusion LOL...  Great videos though overall.  I am learning a lot more from these than other resources online.

Bingobuddha : On June 17, 2008 4:35 PM said:

Got to say I am extremely happy with the videos and the fact this is a free application is a great bonus. I think the presenter of the vids is good for my style of learning and after running through only up to lesson 4 feel really comfortable with it all. V well done and thanks MS ( for a change lol ).

abelanet : On July 02, 2008 7:33 AM said:

Good lesson - I am enjoying all this series

IsrarAli : On July 23, 2008 7:57 AM said:

thanks a lot

cv_vikram : On August 08, 2008 9:21 AM said:

Its a good tutorial thanks....

SALADINE : On August 17, 2008 6:58 AM said:

good article thank you

viki4u : On August 30, 2008 4:07 PM said:

i want to create a form and insert a data in database

and read it in next page pls help me?

susmitadeb : On September 11, 2008 5:25 AM said:

Hi ,

   Nice video.

rajar32 : On September 13, 2008 12:12 AM said:

Awesome...

Basar : On September 21, 2008 7:55 AM said:

Hi,

I followed the tutorial but I also get the "Unable to connect to SQL database" error.

I tried to follow the links romulusc has posted but they didn't help?

Anyone?

Terian : On October 16, 2008 4:35 AM said:

I too get the SQL error using VSExpress 2008

As someone has already states, I'm sure it's because I also didn't install the SQL server express as we use SQL Server 2000 at work.

Is there some setting where I can force ASP.net to look to another server to store it's data?

whatnot : On October 16, 2008 11:57 PM said:

Hi

At 12:45 it's stated that the encoded string held in the viewstate hidden field "helps us retain the state of the text boxes". This seems wrong, in that, why would ASP need to store anything in the page simply to echo the state of the form back the browser?

Between about 25:30 and 27:35 various techniques for maintaining state are summarised. The Application object is discussed as holding stuff for every page and every user. But it is implied that this is not the case for the Profile object.

Surely this is incorrect? (Having tried the code supplied here, I had different browser sessions accessing & updating the same Profile variable, which would suggest it's global to everything).

Has this not confused anyone else??? Or am I being dumb?

djibril_chimere_DIAW : On October 22, 2008 2:45 PM said:

Thanks !

LinhMy : On November 11, 2008 11:42 AM said:

Thank you very much. I like it.

shielin : On November 22, 2008 9:36 PM said:

This video is awesome.

However I am wondering how did you manage to draw a control and place it anywhere in the designer using VS 2005 beta. I am using VS 2008 Express edition, but I can’t do that.

Thanks a lot.

geralddean : On November 23, 2008 10:24 PM said:

another good tutorial.

simple way to pass vars between pages.

interesting.

Martinez79 : On November 26, 2008 10:53 AM said:

At about 22:38 in the video the following code is added to the Web.Config:

 <properties>

   <add name="MyNewProperty" allowAnonymous="true" />

 </properties>

</profile>

In the video the profile object then appears in intellisense. When I tried this, intellisense did not contain a profile object! Am I missing something? I know in the video he is using Visual Web Developer while I am using Visual Studio 2005. Could this be the issue?

Hedwig : On December 01, 2008 4:27 AM said:

Good video....

Came to know the scope of the objects like session,request..etc...

SoulGen : On December 02, 2008 6:38 PM said:

Nice video!

henryw : On December 08, 2008 9:33 PM said:

http://www.idisplayforless.com" style="color:#ffffff;cursor:default">trade show displays

palistinian girl : On December 11, 2008 7:51 AM said:

hiiiiiiiiii everyone ;

i have an assignment in asp.net by using vb , which is u should enter 3 headlines with their pictures , and then the hadline and the picture should appear in the same bage , my problem is that i do not know the code that show the picture.using repeater of course.

any one knows it?

i hope u send the answer on my e_mail pls.

razooon147@hotmail.com

webfabrik : On December 22, 2008 10:22 PM said:

good

MaxfireXSA : On January 04, 2009 4:52 PM said:

Very good.

Reminds me of teleporting from page to page.

bohunt : On February 08, 2009 8:47 AM said:

Very good,

useful tutorial.

MSummers : On February 12, 2009 9:24 AM said:

I like those very simple tricks. Out of the 5 or 6 examples. I thought the quary string and the postback method were the best.

I will use the quary string method in my header banner. Instead of putting a imiage up there I will put a label and use the prperty window for the font, color and size. In my option this will take up less system resourses and the pages will load faster.  I can do this for each web page, and still have a different head banner for each page.

MSummers : On February 12, 2009 9:41 AM said:

This

return ((string)(this.GetPropertyValue("MyNewProperty")));

Should be this

return ((string)(this.GetPropertyValue("MyNewProperty"));

in my option

Umar Farouq : On March 12, 2009 9:55 AM said:

plz hw can i implement session control on my webpages?

thank you

Umar Farouq : On March 12, 2009 9:56 AM said:

plz hw can i implement session control on my webpages?

thank you

tjdarth : On March 13, 2009 1:15 AM said:

I am enjoying these get started series that you all have put together. I do alright until I get to the following piece of code:

<properties>

<add name="MyNewProperty" allowAnonymous="true"/>

</properties>

</profile>

I am not sure where you are getting this code from?? Can someone give me a clue? Thanks in advance , , ,Tom J.

ITIL : On March 23, 2009 2:53 PM said:

Great tutorials, but i am ask this question again en again and if someone does have an best idea i will appreciate it, to let me know which is the best book (ASP.NET) for starter.

Thank to the video tutorials it's anyway helpful....

kgb : On April 28, 2009 5:02 AM said:

Cool !!! also I have faced similar problem but it is Ok (be aware both Martines79 and Adambies's comment if somebody want to see this vidio if your are beginer.

kondin : On May 07, 2009 10:50 AM said:

very useful

sansinfo2008 : On May 11, 2009 5:36 PM said:

some other links for asp.net developers for maintain states are

1). http://www.planetsourcecode.in

eliyas : On July 05, 2009 2:48 PM said:

Hi Guys,

I use VS 2008 and just find a reason for this error:

"The name 'Profile' does not exist in the current context"

The problem was that I created "ASP.NET Web Application" project instead going to File->New->Web Site...

I hope that is will be helpful to someone

deifyed : On July 06, 2009 11:44 AM said:

I'm using C# ASP.Net 3.5 and I had a problem passing a query string from a page to another. After some researching I found that instead of using: Request.Form["myValue"];

I had to use:

Request.QueryString["myValue"];

Hope this helps someone..

Kris

Brewpot : On July 09, 2009 11:10 PM said:

I too received an error with the properties tag. It seems that no matter where in the XML Web.Config file I put Bob's pasted code, I can't seem to get it to recognize it in Default.aspx.cs

<anonymousIdentification enabled="true"/>

<profile enabled="true"/>

<properties>

<add name="MyNewProperty" allowAnonymous="true" />

</properties>

I am using VWD 2008 express

Jay

Jay (at) Brewpot (dot) com if you have any suggestions.

Brewpot : On July 09, 2009 11:30 PM said:

Wow I see my error right there in the cut and copied code.. a bad '/' after the opening profile tag

Posted at 31:55 in the video

edzillion : On September 10, 2009 3:46 PM said:
hmmm. that didn't work, but no explanation? tsk tsk
ilonasn : On September 29, 2009 9:03 AM said:

I have a XML Document but it can't be added.

seyione05 : On October 19, 2009 12:35 PM said:

I will suggest some of this lessons should be make available in pdf for download cos viewing or downloading the video takes a longer time than necessary. Thanks

savillekaufman : On October 21, 2009 12:38 PM said:

At the end of the demo (which is great) you show how to pass a piece of data from a textbox on one page to another page. I do exactly what you do, but continuously get "NullReferenceException was unhandled by user code" even though I have completed the textbox.

Posted at 31:55 in the video

stevebo : On November 09, 2009 10:44 PM said:
To make it work, check out deifyed's comment of 7/6/09

Leave a Comment

You must be logged in to leave a comment. Click here to log in.

Microsoft Communities