Hugoware

The product of a web developer with a little too much caffeine

Archive for August 10th, 2009

The Super Secure HttpRequest

with 3 comments

I’ve been working on a little project lately to see if it is possible to use WebControl inline with ASP.NET MVC. It’s been going well so far, but I encountered a little, tiny, insignificant problem… actually, it’s quite a big problem.

The general idea behind the project was to display the normal view, use the inline code to create a second instance of a page, render the content with the correct ViewState information, and then output the content back onto the ViewPage so it can be used.

Now passing a ViewState into the wrong type of page causes some problems. To get around it we simply rename our ViewState to something else and then change the name back when the page is being loaded in our code. It worked well when I was creating a new HttpRequest object, but the problem is that if you create one manually, it changes to a GET request — not a POST!

At first I figured that I would just get in there and reuse the same HttpRequest and make a few changes, but it wasn’t going to be that easy. The problem is that you just can’t do anything to the HttpRequest — Anything!! Try to change the parameters? Read-Only. Try to inherit from the StateBag? Sealed. Inherit from the HttpRequest itself? Sealed! Holy cow!!

I’ve been battling this quite a bit and at this point I’m feeling defeated (and a little grumpy). I’m trying to find a point that I can make a change to the incoming data, but before the ViewState is loaded by the WebForm page.

After going round and round for awhile I’m starting to think my best (maybe only) option is to get work with the HttpApplication class. Not exactly what I was hoping for, but it may be my only option at this point.

… let’s just hope not everything is read only in this class as well.

Written by hugoware

August 10, 2009 at 1:47 am