473,408 Members | 2,477 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,408 software developers and data experts.

Getting the HttpContext from within a library...

How do I get the current HttpContext when I'm in a Class Library (not from
within an ASP.NET page)? I seem to remember calling GetCurrent from somewhere
before but don't remember the details. The business object is being used from
within a Web app, so there should be an HttpContext available...just can't
get it.

Thanks,
Jay
Mar 10 '06 #1
6 1041
You can use System.Web.HttpContext.Current

"Jay Williams" <Ja*********@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
How do I get the current HttpContext when I'm in a Class Library (not from
within an ASP.NET page)? I seem to remember calling GetCurrent from
somewhere
before but don't remember the details. The business object is being used
from
within a Web app, so there should be an HttpContext available...just can't
get it.

Thanks,
Jay

Mar 10 '06 #2
You should be able to get the Current Context by :

"Jay Williams" <Ja*********@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
How do I get the current HttpContext when I'm in a Class Library (not from
within an ASP.NET page)? I seem to remember calling GetCurrent from
somewhere
before but don't remember the details. The business object is being used
from
within a Web app, so there should be an HttpContext available...just can't
get it.

Thanks,
Jay

Mar 10 '06 #3
Opps sorry:
System.Web.HttpContext.Current

"Jay Williams" <Ja*********@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
How do I get the current HttpContext when I'm in a Class Library (not from
within an ASP.NET page)? I seem to remember calling GetCurrent from
somewhere
before but don't remember the details. The business object is being used
from
within a Web app, so there should be an HttpContext available...just can't
get it.

Thanks,
Jay

Mar 10 '06 #4
Unfortunately, when I type "System.Web...", all Intellisense shows me is
three methods having to do with AspNetHostingPermission.... Nothing else.

That's why I need to call GetCurrent from somewhere, I think.

Jay

"Marina Levit [MVP]" wrote:
You can use System.Web.HttpContext.Current

"Jay Williams" <Ja*********@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
How do I get the current HttpContext when I'm in a Class Library (not from
within an ASP.NET page)? I seem to remember calling GetCurrent from
somewhere
before but don't remember the details. The business object is being used
from
within a Web app, so there should be an HttpContext available...just can't
get it.

Thanks,
Jay


Mar 10 '06 #5
You need to reference System.Web.dll in your project. The VS template for
non-web projects does not include it by default.

"Jay Williams" <Ja*********@discussions.microsoft.com> wrote in message
news:67**********************************@microsof t.com...
Unfortunately, when I type "System.Web...", all Intellisense shows me is
three methods having to do with AspNetHostingPermission.... Nothing else.

That's why I need to call GetCurrent from somewhere, I think.

Jay

"Marina Levit [MVP]" wrote:
You can use System.Web.HttpContext.Current

"Jay Williams" <Ja*********@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
> How do I get the current HttpContext when I'm in a Class Library (not
> from
> within an ASP.NET page)? I seem to remember calling GetCurrent from
> somewhere
> before but don't remember the details. The business object is being
> used
> from
> within a Web app, so there should be an HttpContext available...just
> can't
> get it.
>
> Thanks,
> Jay


Mar 10 '06 #6
The suspense is killing me!

By what?

I think part of your response got lost.

"Anthony Merante" wrote:
You should be able to get the Current Context by :

"Jay Williams" <Ja*********@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
How do I get the current HttpContext when I'm in a Class Library (not from
within an ASP.NET page)? I seem to remember calling GetCurrent from
somewhere
before but don't remember the details. The business object is being used
from
within a Web app, so there should be an HttpContext available...just can't
get it.

Thanks,
Jay


Mar 10 '06 #7

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

Similar topics

2
by: Leon | last post by:
I'm Building a Code Library in VS.NET 2003 to be reference within my ASP.NET web application. However, within my Code Library I have an AppException.vb page that keep receiving the following...
5
by: Leon | last post by:
I'm Building a Code Library in VS.NET 2003 to be reference within my ASP.NET web application. However, within my Code Library I have an AppException.vb page that keep receiving the following error...
1
by: josephpage | last post by:
I have a Visitor class that is defined in a class library. The class has lots of parameters that are pulled from the QueryString, the ReferrerUrl, Cookies, the Session object, etc... I would...
3
by: tshad | last post by:
I have a file that I converted from VB.Net to C# that works fine in VB.Net when I compile but not in C# using the same libraries. The error I am getting is: PageInit.cs(9,7): error CS0138: A...
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: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.