Using session states

Aim:to transfer data accross webpages using session states

I configured my web.config as

<sessionState     cookieless="UseCookies" cookieName="job_SessionId"     regenerateExpiredSessionId="false"   timeout="20"
 mode="InProc"     stateConnectionString="tcpip=127.0.0.1:42424"
 sqlConnectionString="data source=127.0.0.1;Integrated Security=SSPI"
 stateNetworkTimeout="10"
  sqlCommandTimeout="30"
 allowCustomSqlDatabase="false" />

Now in my default page i added the following to a button click event:

If Me.IsPostBack = False Then
            Session("Usersname") = TextBox1

and directed user to  success.aspx page.

And in success.aspx i created a textbox for receiving this textbox text

and the code on pageload is:

      Dim TextBox2 = CType(Session("Usersname"), TextBox) 

     TextBox1.text=textbox2.text

but its causing an error :Object reference not set to an instance of an object.

I tried to pass the whole thing as text.Then no error is shown but my textbox text doesnt change!
 Any way to get rid of this.

 

 


 

 

0
admirer
9/24/2007 4:48:45 AM
asp.net.state-management 8807 articles. 0 followers. Follow

4 Replies
1197 Views

Similar Articles

[PageSpeed] 49
Get it on Google Play
Get it on Apple App Store

If the textbox is not serializable, which I believe is the case you won't be able to store it in the session, so why not just store the actual username:

If Me.IsPostBack = False Then
          
Session("Usersname"
) = TextBox1.Text

then:

TextBox1.text = Session("username")


 


--------------------------------------------------------
Don't forget to click "Mark as Answer" on the post(s) that helped you.

NHibernate with ASP.net Problem-Design-Solution sample application
Scott ASP.net blog

0
scott
9/24/2007 12:21:50 PM

I was right:

".....When you use a session-state mode other than InProc, the session-variable type must be either a primitive .NET type or serializable, because the session-variable value is stored in an external data store. For more information, see Session-State Modes........"

Session State Overview 
http://msdn2.microsoft.com/en-us/library/ms178581.aspx


--------------------------------------------------------
Don't forget to click "Mark as Answer" on the post(s) that helped you.

NHibernate with ASP.net Problem-Design-Solution sample application
Scott ASP.net blog

0
scott
9/24/2007 12:23:46 PM
modified the code as u said,but still no use.Its not showing any text
0
admirer
9/24/2007 6:13:10 PM

if your using SQL as your session state Storage location, try using the code below in your web.config:

<sessionState
            mode="SQLServer"
            sqlConnectionString="data source=127.0.0.1;Integrated Security=SSPI"
            cookieless="false"
            timeout="20"
    />

and going with the defaults to get it working. Also becseu you are using a trusted connection...

"....If you specify a trusted connection to your SQL Server in the configuration file using the sessionState element's sqlConnectionString attribute, the SessionStateModule will connect to SQL Server using SQL Server integrated security. The connection will be made using the ASP.NET process identity or the user credentials supplied for the identity configuration element, if they exist. You can specify that the IIS impersonated identity be used instead by specifying <identity impersonate="true" /> and setting the useHostingIdentity attribute of the sessionState configuration element to false......"

Session-State Modes
http://msdn2.microsoft.com/en-us/library/ms178586(VS.80).aspx


--------------------------------------------------------
Don't forget to click "Mark as Answer" on the post(s) that helped you.

NHibernate with ASP.net Problem-Design-Solution sample application
Scott ASP.net blog

0
scott
9/24/2007 7:47:41 PM
Reply:

Similar Artilces:

Unable to use session state server....requires session state server version 2.0 or above.
So, I have Windows 2003 IIS latest service packs running. Its running .NET 2.0 and .NET 1.1 applications in seperate application pools. Just today I applied the following patch to the server. (The server is not running any 3.0 or 3.5 applications or application pools)  Microsoft .NET Framework 3.5 Service Pack 1 and .NET Framework 3.5 Family Update (KB951847) x86 Microsoft .NET Framework 3.5 Service Pack 1 is a full cumulative update that contains many new features building incrementally upon .NET Framework 2.0, 3.0, 3.5, and includes cumulative servicing upda...

how to use state server to manage sessions
How does one use the state server? Can anyone explain the process how the state server is used or give me some links to which I can refer to, which will explain the same? Basically, we have a web farm environment and we need to persist data across the web farm, for which we intend to use the state server Hi, on the server where State Server will be running, on Services just start the "ASP.NET State Service" service. Then on web.config <sessionState> element in web apps change the mode attribute to "StateServer" and check that stateConnectionString attri...

Session state management using web services.
 Hi all ,i am working of a hospital management system which we desided to develop using atlas frame work. we have created the application main to sections using atlas script call back architecture. we are using scripts to pack the user entered data to the web service and in that web service we are entering the data in to the database.all this happening with out a post back of the page.now comes the problem. we are not being able to handle the user session properties. we came to know that we cant access session variables in web services. we are in a trap now. how we can manage the sessio...

Usage scenarios for view state, session state, application state, cookies
Hi Guys, Im a college student in London with exams starting Monday on ASP.NET with C#.  Id be so grateful if you could provide me with solid real world scenarios/examples of when you would use the following to maintain state and why you would use them in that instance:   View State Session State Application State Cookies Also when would you use SOAP instead of the REST architecture and vice versa and why - again real world usage scenarios?  I note Amazon's web service uses the REST architecture - why is this, why dont they use SOAP. Id be grateful for a timely respon...

Session State and View State
Hi Everyone, Can anybody tellme how are these used in context with ASP.NeT whats their sole purpose?.....and where in programming we use  them? Any links or sources would be good which explains in simple terms.   thanks Simi  ThanksSimi------------&------------"To learn to succeed, you must first learn to fail." -Michael Jordan Here is one of the discussion http://forums.asp.net/t/1145838.aspxMPI never desire to converse with a man who has written more than he hasread. -Samuel Johnson, lexicographer (1709-1784)  Hi There is a video tutorial a...

how to manage session state while using webrequest to login at another URL
plz show me how to do this: When you login at a site, it will store your information in Session or Cookie. So when I make a webrequest to get data from the login page, how can I store and manage the session? I don't exactly understand what you're trying to do. Please explain a little better and we'll try to help.Andrew J Durstewitz, MCSD.NET Senior Software Engineer - Internet Applications http://www.moreheadassociates.com http://adurstewitz.blogspot.com/ sorry, my English is not good enought. in ASP.Net, we can use webrequest and some object to query a URL and then display the...

Unable to make the session state request to the session state server.
 Hello,           I’m receiving this error when I put my website on production."Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection.  If the server is on the local machine, and if the before men...

Unable to make the session state request to the session state server
Hi all, I'm working on the website http://universityauction.net and I was using session variables using InProc session mode to manage session state. This worked fine until I put the website in a load balanced environment, as inproc sessions get lost when jumping from server to server. I decided to move to a state server mode, so I changed my web.config to: <sessionState             mode="StateServer"             stateConnectionString="tcpip=123.456.7.8:42424"      ...

The page requires session state that is no longer available. Either the session has expired, the client did not send a valid session cookie, or the session state history size is too small. Try increas
Hi.. I am making a mobile application using .net framework 2.0. My Application has  web farm scenario so for state management  I am using Sateserver in my application. My application runs fine if I dont use web farm scenario But in case of web farm scenario it is giving me error "The page requires session state that is no longer available. Either the session has expired, the client did not send a valid session cookie, or the session state history size is too small. Try increasing the history size or session expiry limit."   &...

Using SQL Server for Session State Management
Hello, We are implementing session management in a custom database, provided by the following sessionState configuration in web.config: <sessionState mode="SQLServer" stateConnectionString=""    allowCustomSqlDatabase="true"    sqlConnectionString="Data Source=serverName;Database=databaseName;User Id=userName;Password=password"    cookieless="false" timeout="60" /> For reasons to complicated to go into, our company imposes standards on how/where database connection strings get stored. Is there an attribute or method by which I co...

Error: Unable to make the session state request to the session state server
I have session configured in web.config this way:<sessionState mode="StateServer" cookieless="true", timeout="30" stateConnectionString="tcpip=127.0.0.1:42424" />  ASP.NET State Service is started.   I got an error:  Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentContr...

Unable to make the session state request to the session state server #2
We have recently started receiving these errors in the event viewer. We are using the out of proc state server on the same machine. The errors become more frequent, almost like it snowballs until users cannot work. System Info: Windows Server 2003 Standard SP2 , 4 GB of RAM, IIS 6.0, Asp.Net 2.0. What I know for certain: The state server is started and running Recycling the app pool nor restarting IIS fixes the problem Rebooting the machine DOES temporarily fix the problem. I changed the stateNetworkTimeout from 10 to 20 in webconfig and that had no effect. There is usuall...

Unable to make the session state request to the session state server etc.
We are getting an error message "Unable to make the session state request to the session state server..." sporadically in one of our applications.  We have several applications running on a 4-server web farm, and these applications have been in production for a year, so it is not a problem that the server is not reachable, not started, not addressed correctly, etc etc etc. One of the applications *does* put a lot of large datasets into session state.  Is there a limit on the allowable size of a session/cached object?  Also, the application opens several windows at once, ...

"The page requires session state that is no longer available. Either the session has expired, the client did not send a valid session cookie, or the session state history size is too small. Try increa
Hi.. I am making a mobile application using .net framework 2.0. My Application has web farm scenario so for state management I am using Sateserver in my application. My application runs fine if I dont use web farm scenario But in case of web farm scenario it is giving me error "The page requires session state that is no longer available. Either the session has expired, the client did not send a valid session cookie, or the session state history size is too small. Try increasing the history size or session expiry limit." I am not getting why this error is coming ..Though I already h...

Session state, app state or class?
    Greetings     I developing an application which will load a number of panels onto a page    The number of panels to display on the page will depend on data which was     stored in a sql db during setup phase    Which is the most effecient way to get that data?    1) run a class on the server which gets the data from the db and sends it to        the browser each time the page is displayed     2) run the class on the server on app start and then ...

Web resources about - Using session states - asp.net.state-management

Barack Obama speech to joint session of Congress, February 2009 - Wikipedia, the free encyclopedia
Obama's first State of the Union Address was the 2010 State of the Union Address . The speech was delivered on the floor of the chamber of the ...

NRL: Canberra Raiders head to Stromlo for intense running session to counter rule change
The Canberra Raiders are adapting to the NRL's reduction in interchanges and ensuring their front-rowers are fitter to play extra minutes next ...

Perth pub, nightclub opening hours to extend - Sunday Sessions, WA
AS THE east coast of Australia cracks down on late-night drinking, Western Australia is heading in the opposite direction.

Perth Sunday session trading hours extended
Perth pubs and nightclubs can now keep their doors open longer on Sundays under new liquor laws that come into effect this weekend. Perth pubs ...

Aaron Paul Hosts Binge Watchers Anonymous Session for T-Mobile
Every weekday, we bring you the Ad Age/iSpot Hot Spots, new and trending TV commercials tracked by iSpot.tv, a company that catalogs, tags and ...

Should We Fear Peak Human?: Master Post for Uncharted 2015 Brad DeLong-Peter Leyden Session
**Jennie Eliot**: Your Uncharted Interview Video: To Brad, Peter.... >All links in one place: >* [Full video with highlights](http://reinven ...

Jeff Sessions: Supporting Citizenship for Illegals 'Should Be Disqualifying'
Jeff Sessions said supporting citizenship for illegals ought to be “disqualifying” for any candidate running to be the Republican nominee

TWIABP filmed a live session video for "I Can Be Afraid of Anything," add 2nd NYC show to tour
photo: TWIABP at LPR in August (more by Mimi Hong) The World Is A Beautiful Place & I Am No Longer Afraid To Die is on tour now supporting this ...

Saturday Sessions: Jeff Lynne of "Jeff Lynne's ELO" plays "Turn to stone" - Videos - CBS News
Jeff Lynne is one of the most influential rock musicians and producers ever, and is now leading a 21st-century version of a hit-making powerhouse. ...

12 Refugees Implicated In 2015 Terror Cases, Sessions Finds
12 Refugees Implicated In 2015 Terror Cases, Sessions Finds

Resources last updated: 11/26/2015 9:32:54 AM