473,383 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

WebHandler

Hi,

I get this wonderfull message when running my ashx file:
Object reference not set to an instance of an object.

I try to read data from the HttpContext. I think the problem is around
here...
I have allready add IRequiresSessionState, but this did not help.

Suggestion?

Thanks!
Arjen
Nov 8 '06 #1
7 2673
Hello Arjen,

We are really not the clairvoyants to know what's wrong without seing your
code. We need *worked* code to try to help u.

You can find the problem by yourself. see where the problem in line the debugger
screms, set the breakpoint and understand why that referenve was not initialized.

AHi,
AI get this wonderfull message when running my ashx file: Object
Areference not set to an instance of an object.
AI try to read data from the HttpContext. I think the problem is
Aaround
Ahere...
AI have allready add IRequiresSessionState, but this did not help.
ASuggestion?

---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Nov 8 '06 #2
Hmmm....

// Inside my ashx file
ArrayList data = GetData();

// Inside cs file in app_code dir
public static ArrayList GetData()
{
return (ArrayList)HttpContext.Current.Items["MySettings"];
}

Data variable is null.

I believe it have something to do with the processes that are currently
loaded, or not yet loaded... but I don't see a solution.

Arjen
"Michael Nemtsev" <ne*****@msn.comschreef in bericht
news:17***************************@msnews.microsof t.com...
Hello Arjen,

We are really not the clairvoyants to know what's wrong without seing your
code. We need *worked* code to try to help u.

You can find the problem by yourself. see where the problem in line the
debugger screms, set the breakpoint and understand why that referenve was
not initialized.

AHi,
AI get this wonderfull message when running my ashx file: Object
Areference not set to an instance of an object.
AI try to read data from the HttpContext. I think the problem is
Aaround
Ahere...
AI have allready add IRequiresSessionState, but this did not help.
ASuggestion?

---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche


Nov 8 '06 #3
Hi,

Arjen wrote:
Hmmm....

// Inside my ashx file
ArrayList data = GetData();

// Inside cs file in app_code dir
public static ArrayList GetData()
{
return (ArrayList)HttpContext.Current.Items["MySettings"];
}

Data variable is null.

I believe it have something to do with the processes that are currently
loaded, or not yet loaded... but I don't see a solution.

Arjen
Difficult to know exactly what happens. The HttpContext.Current is
likely to exist in an ASHX instance.

I would simply debug the server code. To do that, open the solution with
the ASHX code inside, then select Debug / Attach to process, and select
the ASP.NET process. Then add a breakpoint to the "GetData" line in the
ASHX file. And then call the ASHX from your client. That should allow
you to step in the code.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 8 '06 #4
Hi Arjen,
Data variable is null.
Because HttpContext.Current.Items["MySettings"] is returning null.

Try modifying GetData to assign a default value (empty ArrayList perhaps) in
the case that MySettings hasn't been assigned:

public static ArrayList GetData()
{
ArrayList data = (ArrayList) HttpContext.Current.Items["MySettings"];

if (data = null)
HttpContext.Current.Items["MySettings"] = data = new ArrayList();

return data;
}

--
Dave Sexton

"Arjen" <bo*****@hotmail.comwrote in message
news:ei**********@news5.zwoll1.ov.home.nl...
Hmmm....

// Inside my ashx file
ArrayList data = GetData();

// Inside cs file in app_code dir
public static ArrayList GetData()
{
return (ArrayList)HttpContext.Current.Items["MySettings"];
}

Data variable is null.

I believe it have something to do with the processes that are currently
loaded, or not yet loaded... but I don't see a solution.

Arjen
"Michael Nemtsev" <ne*****@msn.comschreef in bericht
news:17***************************@msnews.microsof t.com...
>Hello Arjen,

We are really not the clairvoyants to know what's wrong without seing your
code. We need *worked* code to try to help u.

You can find the problem by yourself. see where the problem in line the
debugger screms, set the breakpoint and understand why that referenve was
not initialized.

AHi,
AI get this wonderfull message when running my ashx file: Object
Areference not set to an instance of an object.
AI try to read data from the HttpContext. I think the problem is
Aaround
Ahere...
AI have allready add IRequiresSessionState, but this did not help.
ASuggestion?

---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche



Nov 8 '06 #5
Hi Arjen,

I just realized since this is a web app you'll want to synchronize that code:

private static readonly object sync = new object();

public static ArrayList GetData()
{
lock (sync)
{
ArrayList data = (ArrayList) HttpContext.Current.Items["MySettings"];

if (data = null)
HttpContext.Current.Items["MySettings"] = data = new ArrayList();

return data;
}
}|

--
Dave Sexton

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl...
Hi Arjen,
>Data variable is null.

Because HttpContext.Current.Items["MySettings"] is returning null.

Try modifying GetData to assign a default value (empty ArrayList perhaps) in
the case that MySettings hasn't been assigned:

public static ArrayList GetData()
{
ArrayList data = (ArrayList) HttpContext.Current.Items["MySettings"];

if (data = null)
HttpContext.Current.Items["MySettings"] = data = new ArrayList();

return data;
}

--
Dave Sexton

"Arjen" <bo*****@hotmail.comwrote in message
news:ei**********@news5.zwoll1.ov.home.nl...
>Hmmm....

// Inside my ashx file
ArrayList data = GetData();

// Inside cs file in app_code dir
public static ArrayList GetData()
{
return (ArrayList)HttpContext.Current.Items["MySettings"];
}

Data variable is null.

I believe it have something to do with the processes that are currently
loaded, or not yet loaded... but I don't see a solution.

Arjen
"Michael Nemtsev" <ne*****@msn.comschreef in bericht
news:17***************************@msnews.microso ft.com...
>>Hello Arjen,

We are really not the clairvoyants to know what's wrong without seing your
code. We need *worked* code to try to help u.

You can find the problem by yourself. see where the problem in line the
debugger screms, set the breakpoint and understand why that referenve was
not initialized.

AHi,
AI get this wonderfull message when running my ashx file: Object
Areference not set to an instance of an object.
AI try to read data from the HttpContext. I think the problem is
Aaround
Ahere...
AI have allready add IRequiresSessionState, but this did not help.
ASuggestion?

---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche




Nov 8 '06 #6
Well, found the problem...

I add items to the context in the Application_PreRequestHandlerExecute
proces. And this proces is not loaded when browsing to an ashx file.

Now I have to look for a work around.

Thanks!
"Dave Sexton" <dave@jwa[remove.this]online.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hi Arjen,

I just realized since this is a web app you'll want to synchronize that
code:

private static readonly object sync = new object();

public static ArrayList GetData()
{
lock (sync)
{
ArrayList data = (ArrayList)
HttpContext.Current.Items["MySettings"];

if (data = null)
HttpContext.Current.Items["MySettings"] = data = new
ArrayList();

return data;
}
}|

--
Dave Sexton

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl...
>Hi Arjen,
>>Data variable is null.

Because HttpContext.Current.Items["MySettings"] is returning null.

Try modifying GetData to assign a default value (empty ArrayList perhaps)
in the case that MySettings hasn't been assigned:

public static ArrayList GetData()
{
ArrayList data = (ArrayList) HttpContext.Current.Items["MySettings"];

if (data = null)
HttpContext.Current.Items["MySettings"] = data = new ArrayList();

return data;
}

--
Dave Sexton

"Arjen" <bo*****@hotmail.comwrote in message
news:ei**********@news5.zwoll1.ov.home.nl...
>>Hmmm....

// Inside my ashx file
ArrayList data = GetData();

// Inside cs file in app_code dir
public static ArrayList GetData()
{
return (ArrayList)HttpContext.Current.Items["MySettings"];
}

Data variable is null.

I believe it have something to do with the processes that are currently
loaded, or not yet loaded... but I don't see a solution.

Arjen
"Michael Nemtsev" <ne*****@msn.comschreef in bericht
news:17***************************@msnews.micros oft.com...
Hello Arjen,

We are really not the clairvoyants to know what's wrong without seing
your code. We need *worked* code to try to help u.

You can find the problem by yourself. see where the problem in line the
debugger screms, set the breakpoint and understand why that referenve
was not initialized.

AHi,
AI get this wonderfull message when running my ashx file: Object
Areference not set to an instance of an object.
AI try to read data from the HttpContext. I think the problem is
Aaround
Ahere...
AI have allready add IRequiresSessionState, but this did not help.
ASuggestion?

---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche




Nov 8 '06 #7
Hi Arjen,

"ASP.NET Life Cycles"
http://msdn2.microsoft.com/en-us/library/ms227435.aspx

"ASP.NET Application Life Cycle Overview" might be of interest to you for this
problem [link in reference above].

--
Dave Sexton

"Arjen" <bo*****@hotmail.comwrote in message
news:ei**********@news1.zwoll1.ov.home.nl...
Well, found the problem...

I add items to the context in the Application_PreRequestHandlerExecute
proces. And this proces is not loaded when browsing to an ashx file.

Now I have to look for a work around.

Thanks!
"Dave Sexton" <dave@jwa[remove.this]online.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Hi Arjen,

I just realized since this is a web app you'll want to synchronize that
code:

private static readonly object sync = new object();

public static ArrayList GetData()
{
lock (sync)
{
ArrayList data = (ArrayList)
HttpContext.Current.Items["MySettings"];

if (data = null)
HttpContext.Current.Items["MySettings"] = data = new
ArrayList();

return data;
}
}|

--
Dave Sexton

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl. ..
>>Hi Arjen,

Data variable is null.

Because HttpContext.Current.Items["MySettings"] is returning null.

Try modifying GetData to assign a default value (empty ArrayList perhaps)
in the case that MySettings hasn't been assigned:

public static ArrayList GetData()
{
ArrayList data = (ArrayList) HttpContext.Current.Items["MySettings"];

if (data = null)
HttpContext.Current.Items["MySettings"] = data = new ArrayList();

return data;
}

--
Dave Sexton

"Arjen" <bo*****@hotmail.comwrote in message
news:ei**********@news5.zwoll1.ov.home.nl...
Hmmm....

// Inside my ashx file
ArrayList data = GetData();

// Inside cs file in app_code dir
public static ArrayList GetData()
{
return (ArrayList)HttpContext.Current.Items["MySettings"];
}

Data variable is null.

I believe it have something to do with the processes that are currently
loaded, or not yet loaded... but I don't see a solution.

Arjen
"Michael Nemtsev" <ne*****@msn.comschreef in bericht
news:17***************************@msnews.micro soft.com...
Hello Arjen,
>
We are really not the clairvoyants to know what's wrong without seing
your code. We need *worked* code to try to help u.
>
You can find the problem by yourself. see where the problem in line the
debugger screms, set the breakpoint and understand why that referenve
was not initialized.
>
AHi,
AI get this wonderfull message when running my ashx file: Object
Areference not set to an instance of an object.
AI try to read data from the HttpContext. I think the problem is
Aaround
Ahere...
AI have allready add IRequiresSessionState, but this did not help.
ASuggestion?
>
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour
>
"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche
>
>




Nov 8 '06 #8

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

Similar topics

2
by: Christopher Ambler | last post by:
I'm wondering if there's a solution here - I have an ASPX page with a sole purpose of scaling an image. The ASPX page contains a single line with the codebehind tag, and the .cs file contains...
2
by: Bart Adriaanse | last post by:
As VS.NET is not being very supportive in creating a ASHX http handler, i would like to use a codebehind VB file as to get intellisense features etc on it's code. I just cannot get ashx to work...
4
by: Detlef Huettenbach | last post by:
I was trying to convert a Windows Forms prototype application to an ASP.NET solution that makes use of loading data streams into the Image Web/Windows control. For WinForms no problem. However in...
3
by: Ivonne Riedel | last post by:
Hi everybody, I have got a serious problem building an HTTPHandler in codebehind style. I made the following steps: Create an ASP .net Website project Add a generic handler. Rewrite this...
10
by: JJ | last post by:
How can I get a SiteMapNodeCollection to output as an XML file?
0
by: Sam Collett | last post by:
Is it possible to execute a WebHandler (ashx file) from another page (or another WebHandler) and return the contents? I am aware of using WebRequest and HttpWebResponse but wouldn't that be an...
0
by: =?Utf-8?B?YmlsbCB0aWU=?= | last post by:
- In my brand new installation of the MSDN library, the WebHandler is not included. - In the online MSDN, a note says "This attribute is included for compatibility with previous versions of...
1
by: Sebastian Paul | last post by:
Hi, the task is easy: I want to have the Cache-Control set to Public. void IHttpHandler.ProcessRequest(HttpContext context) { const int maxAge = 10;...
1
by: =?Utf-8?B?Z2hhdXNl?= | last post by:
I'm trying to stream in image from another domain asynchronously. My ashx looks like this: <%@ WebHandler Language="VB" Class="Handlers.AsyncImageHandler" Debug="true" %> Here is the vb:...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.