473,806 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting error while setting session value

Hi,
When i try to set a value for a session variable I'm getting a object
refence not set error

I tried two methods as below
HttpContext.Cur rent.Session.Ad d("AppStartTime ", DateTime.Now);
HttpContext.Cur rent.Session["AppStartTi me"] = DateTime.Now;

For the above two methods I'm getting error as
"Object reference not set to an instance of an object."
Kindly help me out.

Thanks,
Sony
Jun 27 '08 #1
2 2795

Hi Sony,

I tried the code and it works fine.

protected void Page_Load(objec t sender, EventArgs e)
{
HttpContext.Cur rent.Session["AppStartTi me"] = DateTime.Now;
Response.Write( Session["AppStartTi me"].ToString());
}

Regards,
Manish
www.componentone.com
"so*********@go oglemail.com" wrote:
Hi,
When i try to set a value for a session variable I'm getting a object
refence not set error

I tried two methods as below
HttpContext.Cur rent.Session.Ad d("AppStartTime ", DateTime.Now);
HttpContext.Cur rent.Session["AppStartTi me"] = DateTime.Now;

For the above two methods I'm getting error as
"Object reference not set to an instance of an object."
Kindly help me out.

Thanks,
Sony
Jun 27 '08 #2
On Jun 12, 12:11 pm, Manish <Man...@discuss ions.microsoft. comwrote:
Hi Sony,

I tried the code and it works fine.

protected void Page_Load(objec t sender, EventArgs e)
{
HttpContext.Cur rent.Session["AppStartTi me"] = DateTime.Now;
Response.Write( Session["AppStartTi me"].ToString());
}

Regards,
Manishwww.compo nentone.com

"sony.m.2...@go oglemail.com" wrote:
Hi,
When i try to set a value for a session variable I'm getting a object
refence not set error
I tried two methods as below
HttpContext.Cur rent.Session.Ad d("AppStartTime ", DateTime.Now);
HttpContext.Cur rent.Session["AppStartTi me"] = DateTime.Now;
For the above two methods I'm getting error as
"Object reference not set to an instance of an object."
Kindly help me out.
Thanks,
Sony
Hi,
My class implements IHttpModule
and I'm assigning the session value at onbeginrequest method

public class TestHTTPModule : IHttpModule
{
public void Init(HttpApplic ation application)
{
application.Beg inRequest +=
(new EventHandler(th is.Application_ BeginRequest));
}
private void Application_Beg inRequest(Objec t source,
EventArgs e)
{
HttpContext.Cur rent.Session.Ad d("AppStartTime ",
DateTime.Now);
HttpContext.Cur rent.Session["AppStartTi me"] = DateTime.Now;
}
}

If u try like above you will get the error message.
How to solve this?

Thanks,
Sony
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5042
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I double-checked the path to my error log. It is in /var/www/logs/php_error_log Thanks. :) -Wayne Stevenson
4
1668
by: Bryan Tang | last post by:
I built an ASP to search the content in index server. It is ok if search in English. Whenever I search in Chinese, I will got the following error message, CreateRecordset ?u?~ '80004005' £gLak?u¢DXao?u?~ /search/query.asp, |C203
10
2729
by: Brian Conway | last post by:
I have no idea what is going on. I have a Login screen where someone types in their login information and this populates a datagrid based off of the login. Works great in debug and test through VS, however, when I change to release and put it out on the web it fails giving me the following error message The underlying connection was closed. Could not establish a trust relationship with the remote server.
0
5910
by: Adam Getchell | last post by:
I'm attempting to write a custom Authentication module using http://www.15seconds.com/Issue/020417.htm I looked at http://support.microsoft.com/default.aspx?scid=kb;EN-US;307996, but it doesn't setup things the way I want (ie, I want to integrate into an existing web application). So I want to deny unauthenticated users access to everything except the default page. I have an error in web.config. When I comment out these lines: ...
1
2854
by: Ramanfromoz | last post by:
Hi, Developing a new we application. Everything okay on my local WIN XP PROFESSIONAL, IIS 5.0 running locally. The website is running smoothly. Now, the same code I am copying over to a WINDOWS 2003 SERVER, I created a new website, allocated port number 6000. Created a release version on my local machine and copied the WEB project from my local to http://ACTYD003:6000
15
2334
by: jkmambo | last post by:
Session data is getting lost in PHP version 4.4.1 which used to work in version 4.3.3 The code is similar to the one below Assume the file is called count.php which requires a parameter productid; session_start(); if (!isset($_SESSION)) $_SESSION = 0;
2
13728
by: ronchese | last post by:
I'm noticing this since I started developing a website project: my session variables are getting empty! I did a real easy test, and I checked my session variable is getting empty!! What is happening? For example (VS2005, IE6/7, running in filesystem): - In the Page_load of page1.aspx: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Throw New Exception("Error is thrown") End Sub
1
1908
by: spitapps | last post by:
I want to have sessions on my website, this is my web.config file: <configuration> <appSettings/> <connectionStrings/> <system.web> <sessionState mode="InProc" cookieless="UseCookies" timeout="20" cookieName="whatever"></sessionState> <!-- Set compilation debug="true" to insert debugging
2
2437
by: preeti13 | last post by:
Hi guys i am here with my another probelm please help me.trying insert the value into the data base but getting the null value error .I am getting thsi error Cannot insert the value NULL into column 'EmployeeID', table 'Accomplishments.dbo.Accomplishment'; column does not allow nulls. INSERT fails. The statement has been terminated. and my code is this using System; using System.Collections;
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10364
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10370
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10109
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3849
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.