SOLUTION - HttpWebRequest raw headers

by jfisch 28. July 2009 18:47

I've been bothered by being constrained by the header validation within the HttpWebRequest object several times.  The constraints, IMO, are a little too constrictive on what can and can't be added to the HttpWebRequest object.  Here's a solution.  I've implemented the methods as extension methods on the HttpWebRequest object.  The first gives you internal access to the WebHeaderCollection object that the HttpWebRequest provides access to, the second HeadersRaw provides completely uninhibited access to the header collection via the WebHeaderCollection object's internal NameValueCollection.

I haven't done a great deal of testing on this particular solution, but it should be pretty straight forward to utilize.  I'm a little weary of potential threading issues given that I've implemented this as an extension method and what used to be fields of an object are now static fields.  So, do some testing if you're planning on using this in a multi-threaded scenario.  To utilize, you'll want to add the WebRequest namespace (or whatever you rename it as) to your sourcecode, then you'll have access to the raw header objects via the following:

WebHeaderCollection header1 = request.HeadersUnAuthenticated();

or 

NameValueCollection header2 = request.HeadersRaw();

WebRequest.zip (3.30 kb)

Good luck!

Jeff

Tags: , , ,

ASP.NET

Comments

2/22/2012 3:40:17 AM #

Shantel Satter

I have to convey my gratitude for this article copy article author regarding helping me from this problem. Due to looking at through the world-wide-web as well as obtaining proposals that were not effective, I used to be considering playing has been more than. Getting still living without as much strategies to the down sides you have resolved all through your website is a critical situation, plus the types that might possess in the damaging way broken my profession basically hadn't come across your web blog site. The great instruction as well as kindness in playing with every single product has been useful. I don't know things i would have completed if I hadn't found this type of level such as this. I'm also able to at this point look ahead to my personal potential. Thank you very much for this remarkable as well as successful manual. I won't think twice to relate the sites to anybody which should have tips about this case.

Shantel Satter United States

2/22/2012 3:40:21 AM #

Rocky Hartse

I must express my personal understanding for this article copy article author regarding bailing myself out of this concern. As a result of examining through the world-wide-web as well as finding recommendations that were not really powerful, I had been pondering my entire life has been more than. Getting alive minus the strategies to the issues you have.

Rocky Hartse United States

2/22/2012 3:45:45 AM #

sahibinden satılık

This is getting a bit more subjective, but I much prefer the Zune Marketplace. The interface is colorful, has more flair, and some cool features like 'Mixview' that let you quickly see related albums, songs, or other users related to what you're listening to. Clicking on one of those will center on that item, and another set of "neighbors" will come into view, allowing you to navigate around exploring by similar artists, songs, or users. Speaking of users, the Zune "Social" is also great fun, letting you find others with shared tastes and becoming friends with them. You then can listen to a playlist created based on an amalgamation of what all your friends are listening to, which is also enjoyable. Those concerned with privacy will be relieved to know you can prevent the public from seeing your personal listening habits if you so choose.

sahibinden satılık United States

2/22/2012 3:51:15 AM #

locksmith balmain

Certainly agree with simply what you whispered. Your clarification was surely the easiest to comprehend. I  tell you, I habitually become irritated any time folks discuss problems that these persons evidently don’t understand  about. You were able to hit the nail on the head as well as spelled out the entire thing with out complication.  Perhaps, individuals could take a signal. Will likely be back to acquire further. Appreciate it.

locksmith balmain United States

2/22/2012 3:56:26 AM #

kiln formed glass

I personally have embraced the new technologies and the CMS platforms, I think the new tools only make the web designs better. I am glad that new technologies are coming out in web design that make things easier, improved, and better looking for design.

kiln formed glass United States

2/22/2012 4:11:26 AM #

Bryan

I like to always read the articles in this site was my favorite

Bryan United States

2/22/2012 4:21:04 AM #

swim spa

Hello this is kind of of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML. I'm starting a blog soon but have no coding know-how so I wanted to get advice from someone with experience. Any help would be enormously appreciated!

swim spa United States

2/22/2012 4:27:40 AM #

digestive system diseases

It is best to participate in a contest for probably the greatest blogs on the web. I will advocate this web site!

digestive system diseases United States

2/22/2012 4:38:38 AM #

Clyde Shekarchi

I’d need to check with you here. Which isn't something I usually do! I get pleasure from reading a publish that can make individuals think. Additionally, thanks for permitting me to remark!

Clyde Shekarchi United States

2/22/2012 4:46:33 AM #

coconut oil benefits

Definitely visualize what we mentioned. Ones most liked justification have also been with the web the easiest element to look at straight into accout regarding. My spouse and i say to an individual, We absolutely get agitated though persons take into consideration problems that they will plainly do not understand with regards to. An individual were able to reach your claw upon the most notable as well as outlined out the whole thing without necessity side effect, other folks can have a indication. Might be back again to obtain additional. Thanks!

coconut oil benefits United States

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen