Parsing Request.Headers.ToString()

Discussion in 'ASP .Net' started by sck10, Apr 13, 2006.

  1. sck10

    sck10 Guest

    Hello,

    I am using the following to retrieve header information from a webpage:
    Request.Headers.ToString(). What I get is a huge string of data. How do I
    go about extracting just the part that I need? Buried in the header is an
    example: &SM_USER=sck10&

    What I need to get is the value for SM_USER.
    --
    Thanks in advance,

    sck10
    sck10, Apr 13, 2006
    #1
    1. Advertising

  2. sck10

    Jeff Dillon Guest

    Request.Item("SM_USER")

    "sck10" <> wrote in message
    news:%...
    > Hello,
    >
    > I am using the following to retrieve header information from a webpage:
    > Request.Headers.ToString(). What I get is a huge string of data. How do
    > I
    > go about extracting just the part that I need? Buried in the header is an
    > example: &SM_USER=sck10&
    >
    > What I need to get is the value for SM_USER.
    > --
    > Thanks in advance,
    >
    > sck10
    >
    >
    Jeff Dillon, Apr 14, 2006
    #2
    1. Advertising

  3. Hi,

    Request.Headers is just a standard NameValueCollection of HTTP headers,
    so you can use standard collection syntax to retrieve a single header's
    value, e.g.

    string smUser = Request.Headers["SM_USER"];

    HTH,
    Chris
    Chris Fulstow, Apr 14, 2006
    #3
  4. Hi sck10,

    As other member has mentioned, the ASP.NET HttpRequest.Headers is a string
    based key/value collection, so you can access a certain header in it
    through its headername. e.g:

    foreach (string key in Request.Headers.Keys)
    {
    Response.Write("<br>" + key + ": " + Request.Headers[key]);
    }

    Hope this helps.

    Regards,

    Steven Cheng
    Microsoft Online Community Support


    ==================================================

    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.

    ==================================================


    This posting is provided "AS IS" with no warranties, and confers no rights.



    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    Steven Cheng[MSFT], Apr 14, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?S2V2aW4gQnVydG9u?=

    Pre-Send Request Headers, Pre-Send Request Content

    =?Utf-8?B?S2V2aW4gQnVydG9u?=, Dec 31, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,042
    =?Utf-8?B?S2V2aW4gQnVydG9u?=
    Dec 31, 2004
  2. TJS
    Replies:
    1
    Views:
    683
  3. Replies:
    1
    Views:
    2,152
    Bruce Barker
    May 3, 2005
  4. dont bother
    Replies:
    0
    Views:
    787
    dont bother
    Mar 3, 2004
  5. Fergus McMenemie

    LibXML element->toString vs document->toString

    Fergus McMenemie, Jul 12, 2012, in forum: Perl Misc
    Replies:
    5
    Views:
    612
    Fergus McMenemie
    Jul 17, 2012
Loading...

Share This Page