Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

XmlTextReader - need to provide a User-Agent header to HTTP request

$
0
0

In an ASP.Net app (Visual Studio 2010 - VB.net) web application;

I need to add User-Agent header info to a call to a National Weather Service website \ XML file, and I'm not sure how to add this to my apps code.

Apparently the NWS has added this requirement recently, and it has disabled an application that I have had in service for several years.

"...Applications accessing resources on weather.gov need to provide a User-Agent header in any HTTP request. Requests without a user agent are automatically blocked...." "...We recommend providing a user agent string in the following format:   ApplicationName/vX.Y (http://your.app.url/; contact.email@example.com) ..."

...Well that's just great thanks NWS.

So, my existing code  is very simple

Dim xtrNWSFeed As XmlTextReader

Try    xtrNWSFeed = New XmlTextReader(strWeatherSrcFilePath)

Currently (in code I have omitted for brevity) strWeatherSrcFilePath is assembled to look like this:http://w1.weather.gov/xml/current_obs/KMCI.xml

...Further down in the code I simply begin to read the XML file

Try   While xtrNWSFeed.Read()   If XmlNodeType.Element Then    If xtrNWSFeed.Name = "location" Then

' go to its text node strLocation = (xtrNWSFeed.ReadString)

... and so on...

 I can't find where to place the User-Agent header information that the NWS now requires.


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>