locked
how to put Custom Header value in Http request without a key ? RRS feed

  • Question

  • User1209762498 posted

    Hi, I need to put a custom value in HttpWebRequest header without a key for it. HttpRequest.Headers is a NameValue collection and the server doesn't honor an header entry without a Name. Any help is highly appreciated.

    Eg: my Http Header content should be  (I am able to do this in Fiddler, but not in C#):

    User-Agent: SSL TestApp Content-Type: x-Visa-II/x-auth

    82D0.99999503U

    - San

    Saturday, December 13, 2014 1:57 PM

Answers

  • User-434868552 posted

    @santosai143     welcome to forums.asp.net

    http://msdn.microsoft.com/en-us/library/system.web.httprequest.headers(v=vs.110).aspx "HttpRequest.Headers Property"

    santosai143

    I need to put a custom value in HttpWebRequest header without a key for it

    Why?

    public NameValueCollection Headers { get; }  // this is readonly

    what happens if you make your 82D0.99999503U the key?  then setting the corresponding value to String.Empty?

    Just an idea.

    F.Y.I.:  http://weblogs.asp.net/gerrylowry/clarity-is-important-both-in-question-and-in-answer 

    edit:    how are you creating the header since there is no setter?  show us your code. end edit.

    edit2:  just because Fiddler lets you create many things does not mean that breaking the NameValueCollection is legal AFAIK.

               just because you can does not mean you should.

               remember, Fiddler is a tool for testing and experimenting.

               Eric Lawrence, author of Fiddler, has a forum ... you might consider asking for advice there;

               i wish i knew 10% of what Eric lives and breathes.

    end edit2.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, December 14, 2014 1:44 AM