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: Programming | Testing
Monday, May 28, 2007 2:23:03 PM (Central Daylight Time, UTC-05:00) #    Comments [4]  | 

 

Tuesday, June 05, 2007 8:10:39 PM (Central Daylight Time, UTC-05:00)
Just curious, but why do you avoid the Session?
Tuesday, June 05, 2007 9:39:20 PM (Central Daylight Time, UTC-05: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).

Wednesday, June 06, 2007 12:16:36 AM (Central Daylight Time, UTC-05: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 9:12:56 PM (Central Daylight Time, UTC-05: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):

Live Comment Preview
All content © 2010, Christopher May, Inc
Open Job Positions
On this page
Google Ads
This site
Calendar
<May 2007>
SunMonTueWedThuFriSat
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789
Archives
Sitemap
Blogroll OPML
Disclaimer

Powered by: newtelligence dasBlog 2.3.9074.18820

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: