Parsing Request.Headers.ToString()

S

sck10

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.
 
C

Chris Fulstow

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
 
S

Steven Cheng[MSFT]

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.)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top