I remember it took me forever to figure this out and the headache before learning this that it caused. Because .NET is strongly typed you are unable to access the Session, Request, or Response (and many other Http/Web object) from within a class library like you can writing in a code-behind file or on the page itself. I battled for weeks (I almost think months) trying to find ways of passing information between my pages and class library, when I finally found the answer:
HttpContext.Current.Session
HttpContext.Current.Response
HttpContext.Current.Request
Thats it. No special magic, just use the HttpContext.Current Object within a class library that is being used within the context of a website. Once I found that, it made life so much easier, and if you are reading this, I hope it makes your life easier too.
Related Posts
- CSS - ID vs Class After hacking apart & cleaning up code for the better part of the day, I've decided to set the record straight about CSS, IDs, and Classes. The question is "when should I use an ID, and when should I use a class?" Is it that big of a deal? The...
- Retrieve Current Module/Controller/Action inside View Script / Layout Script Before I forget to do this again I'm going to make a post on how to get the current Module, Controller, and Action while inside a View Script or Layout Script. Here is the most correct way to do it: PLAIN TEXT PHP: $front = Zend_Controller_Front::getInstance(); $request = $front->getRequest(); ...
- ASP .NET & System.Threading.ThreadAbortException Error While doing some work today I started to run into a ThreadAbortException error. While debugging it spit back this error: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack. I was really confused because everything seemed to be...
- SoapUI - a simple and raw Java SOAP Client There are times when you need a "raw" SOAP client to see the exact messages being sent to and from a Soap Sever. This is especially important for developers who are hosting a soap server for an API. In my example, PHP was throwing an error, but I couldn't see...
- PHP Singletons, Sub-Classing, and HAS-A Relationships I've been very busy these last fews weeks and have neglected making any posts. While there are a variety of subjects I'd love to post about, they'll most likely have to wait until the next year. However, I thought I might be able to throw up a quick example of...

Recent Comments