User-Agent problem

J

Jeff

hey

..NET 2.0

In my code I've been accessing a xml file like this:
string url = <url> // for example http://www.test.com/default.xml
XmlReader reader = XmlReader.Create(url);

But now I need to add the User-Agent to this request. the Url I request
doesn't work if I don't provide the User-Agent info also...

Any ideas on how to add the User-Agent to the url?
 
J

Jon Skeet [C# MVP]

Jeff said:
.NET 2.0

In my code I've been accessing a xml file like this:
string url = <url> // for example http://www.test.com/default.xml
XmlReader reader = XmlReader.Create(url);

But now I need to add the User-Agent to this request. the Url I request
doesn't work if I don't provide the User-Agent info also...

Any ideas on how to add the User-Agent to the url?

You'd need to do more work to retrieve the data - use the WebClient or
WebRequest classes.
 

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

Top