I'm not sure if this is the right place to post this...
The thing is that I'm trying to fetch a Xml file from a url coz I don't want to save it everytime a post is made.
string
uri = @"http://www.whatever.com/myxmlfile"; //this returns an xml file!
XmlReaderSettings xs =
new XmlReaderSettings();
XmlReader x =
XmlReader.Create(uri, xs);
But when I do this, it gives me the following error: The remote server returned an error: (503) Server Unavailable.
I would appreciate any help.
Thx
xmlXmlReaderASP.NETC#
André da Silva Carrilho
http://www.acarrilho.com/
If the post has been answered please marke it as Answered :-)
NOTE:If you find my response contains a reference to a third party World Wide Web site, I am providing this information as a convenience to you.Microsoft does not control these sites and has not tested any software or information found on these sites; therefore,Microsoft cannot make any representations regarding the quality,safety, or suitability of any software or information found there.
__________________________________________________
Sincerely,
Young Fang
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Yah, I can. When doing a post with HttpRequest I had to specify ther UserAgent otherwise it didn't work. I guess the server required that header for the request to be successful.
But thanks for your post anyhow!
Good day to you!
André da Silva Carrilho
http://www.acarrilho.com/
If the post has been answered please marke it as Answered :-)
I would retrieve xml data in code behind using HttpWebRequest in which you could use UserAgent.
Here is a sample:
// Create a new 'HttpWebRequest' object to the mentioned URL.
HttpWebRequest myHttpWebRequest=(HttpWebRequest)WebRequest.Create("http://www.contoso.com");
myHttpWebRequest.UserAgent=".NET Framework Test Client";
// Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable.
HttpWebResponse myHttpWebResponse=(HttpWebResponse)myHttpWebRequest.GetResponse();
// Display the contents of the page to the console.
Stream streamResponse=myHttpWebResponse.GetResponseStream();
StreamReader streamRead = new StreamReader( streamResponse );
Char[] readBuff = new Char[256];
int count = streamRead.Read( readBuff, 0, 256 );
Console.WriteLine("\nThe contents of HTML Page are :\n");
while (count > 0)
{
String outputData = new String(readBuff, 0, count);
Console.Write(outputData);
count = streamRead.Read(readBuff, 0, 256);
}
// Release the response object resources.
streamRead.Close();
streamResponse.Close();
myHttpWebResponse.Close();
NOTE:If you find my response contains a reference to a third party World Wide Web site, I am providing this information as a convenience to you.Microsoft does not control these sites and has not tested any software or information found on these sites; therefore,Microsoft cannot make any representations regarding the quality,safety, or suitability of any software or information found there.
__________________________________________________
Sincerely,
Young Fang
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
andrecarrilh...
Participant
966 Points
223 Posts
The remote server returned an error: (503) Server Unavailable
Jan 15, 2007 04:43 PM|LINK
Hi
I'm not sure if this is the right place to post this...
The thing is that I'm trying to fetch a Xml file from a url coz I don't want to save it everytime a post is made.
string
uri = @"http://www.whatever.com/myxmlfile"; //this returns an xml file!XmlReaderSettings xs = new XmlReaderSettings();
XmlReader x = XmlReader.Create(uri, xs);
But when I do this, it gives me the following error: The remote server returned an error: (503) Server Unavailable.
I would appreciate any help.
Thx
xml XmlReader ASP.NET C#
http://www.acarrilho.com/
If the post has been answered please marke it as Answered :-)
Young Fang -...
All-Star
17147 Points
1620 Posts
Re: The remote server returned an error: (503) Server Unavailable
Jan 16, 2007 12:32 AM|LINK
Hey
It looks like remote server is not available.
Can you access that URL form IE?
__________________________________________________
Sincerely,
Young Fang
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
andrecarrilh...
Participant
966 Points
223 Posts
Re: The remote server returned an error: (503) Server Unavailable
Jan 16, 2007 08:41 AM|LINK
Hi
Yah, I can. When doing a post with HttpRequest I had to specify ther UserAgent otherwise it didn't work. I guess the server required that header for the request to be successful.
But thanks for your post anyhow!
Good day to you!
http://www.acarrilho.com/
If the post has been answered please marke it as Answered :-)
Young Fang -...
All-Star
17147 Points
1620 Posts
Re: The remote server returned an error: (503) Server Unavailable
Jan 17, 2007 12:55 AM|LINK
Hey
I would retrieve xml data in code behind using HttpWebRequest in which you could use UserAgent.
Here is a sample:
// Create a new 'HttpWebRequest' object to the mentioned URL. HttpWebRequest myHttpWebRequest=(HttpWebRequest)WebRequest.Create("http://www.contoso.com"); myHttpWebRequest.UserAgent=".NET Framework Test Client"; // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. HttpWebResponse myHttpWebResponse=(HttpWebResponse)myHttpWebRequest.GetResponse(); // Display the contents of the page to the console. Stream streamResponse=myHttpWebResponse.GetResponseStream(); StreamReader streamRead = new StreamReader( streamResponse ); Char[] readBuff = new Char[256]; int count = streamRead.Read( readBuff, 0, 256 ); Console.WriteLine("\nThe contents of HTML Page are :\n"); while (count > 0) { String outputData = new String(readBuff, 0, count); Console.Write(outputData); count = streamRead.Read(readBuff, 0, 256); } // Release the response object resources. streamRead.Close(); streamResponse.Close(); myHttpWebResponse.Close();For details see http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.useragent.aspx
__________________________________________________
Sincerely,
Young Fang
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.