By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,866 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,866 IT Pros & Developers. It's quick & easy.

How to access HttpContext from standalone class

P: n/a
I'm getting "'HttpContext' does not exist in the class or namespace
'System.Web'" from trying to build (with Microsoft Development
Environment 2003, ver. 7.1.3088, .NET Framework 1.1, ver. 1.1.4322)
something like this:

using System;
using System.Collections;
using System.Collections.Specialized;
using System.Text;

namespace A
{
public class A
{
public A()
{
// get value from HTTP header
NameValueCollection collection;
collection = System.Web.HttpContext.Current.Request.ServerVaria bles;

// etc., etc.
}
}
}
What I would like to do is to create a standalone class "A", which can
be used in an aspx file like so:

<%@ Import Namespace="A" %>
<script language="C#" runat="server">
void Page_Load( Object Sender, EventArgs e ) {
A a = new A();
// etc, etc.
}

I feel pretty stupid staring at a message like that, after having
checked
http://msdn.microsoft.com/library/de...classtopic.asp...

Nov 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
ju****@firma.tele.dk wrote:
I'm getting "'HttpContext' does not exist in the class or namespace
'System.Web'" from trying to build (with Microsoft Development
Environment 2003, ver. 7.1.3088, .NET Framework 1.1, ver. 1.1.4322)
something like this:

using System;
using System.Collections;
using System.Collections.Specialized;
using System.Text;

namespace A
{
public class A
{
public A()
{
// get value from HTTP header
NameValueCollection collection;
collection = System.Web.HttpContext.Current.Request.ServerVaria bles;

// etc., etc.
}
}
}
What I would like to do is to create a standalone class "A", which can
be used in an aspx file like so:

<%@ Import Namespace="A" %>
<script language="C#" runat="server">
void Page_Load( Object Sender, EventArgs e ) {
A a = new A();
// etc, etc.
}

I feel pretty stupid staring at a message like that, after having
checked
http://msdn.microsoft.com/library/de...classtopic.asp...


Is that class "A" defined in a separate class-library project?
Did you reference the System.Web dll there?
Hans Kesting
Nov 17 '05 #2

P: n/a
Yes (as in File->New->Project->Class Library).

Not besides fully qualifying HttpContext. But it makes no difference if
I include a "using System.Web;" statement. Can I reference System.Web
in another way?

Nov 17 '05 #3

P: n/a
jul...@firma.tele.dk:

"Not besides fully qualifying HttpContext. But it makes no difference
if
I include a "using System.Web;" statement. Can I reference System.Web
in another way? "

I think what Hans means is, did you add a reference to System.Web.dll
in your class library project?

Jason Gorman
http://www.parlezuml.com
UML tutorials for Java & .NET

Nov 17 '05 #4

P: n/a
No - but I should have. It is now working. Thanks for the help, both!

Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.