Simulating HttpContext #
Update: Phil Haack has updated his HttpContext Simulator with some new goodies.

Here is an article by Haacked showing how one can create a test friendly httpcontext.

I modified his example some and started using it in some tests; works very nice!

Here is another implementation based on Haack's example that is supposed to also work with session.

I almost NEVER use session if I can avoid it, but still this could come in handy.

Categories:  | 
Monday, May 28, 2007 1:23:03 PM (Central Standard Time, UTC-06:00) #    Comments [4]  | 

 

Tuesday, June 05, 2007 7:10:39 PM (Central Standard Time, UTC-06:00)
Just curious, but why do you avoid the Session?
Tuesday, June 05, 2007 8:39:20 PM (Central Standard Time, UTC-06:00)
It seems like there is almost always a better place to put stuff than in session.

I encrypt data in the querystring to pass data between pages that I don't want the user to mess with.

A lot of my apps run on a cluster, which is pretty good, but there is always a chance that the user will hit the wrong server, and b/c we are not using state server, their session will be empty.

It also seems like a good way to run into problems, 2 programmers can overwrite each others values in session, if you are looking for a "OrderID" in session, and 2 developers are both using that name for different things in their sections of the application...

For our site, session expires a lot faster than their authentication ticket, so if you are in the middle of working on something that is expecting a value in sesssion, and session has expired, then you are SOL.

Session also dies if your asp.net process recycles.

Some of these problems are fixed if you use a state server... but alas we don't (yet).

Tuesday, June 05, 2007 11:16:36 PM (Central Standard Time, UTC-06:00)
I'm a huge fan of simple, clean URLs, so I'm generally against stashing stuff there if I can avoid it.

One of the first things I did when I started the current project (my first ASP project of any kind) was to build a clone of Ruby on Rails' Flash, which is a fantastic little idea: it allows me to stash stuff in the Session specifically and only for the next Request, so if a POST comes in, I stash the results in the Flash, then redirect to another page. On that redirected GET I can then access all that stuff. This is currently the only thing I'm using the Session for, but it's reason enough for me.
Wednesday, June 06, 2007 8:12:56 PM (Central Standard Time, UTC-06:00)
Thats interesting. I wasn't aware of that.

Thanks for posting.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

All content © 2008, Christopher May, Inc
Open Job Positions
On this page
Google Ads
This site
Calendar
<November 2008>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456
Archives
Sitemap
Blogroll OPML
Disclaimer

Powered by: newtelligence dasBlog 1.9.6264.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts


Pick a theme: