You might want to use a HttpWebRequest to get the page (in conjunction with a StreamReader) before reading it into the dataset.
public String GetPage(string strURL)
{ // the html retrieved from the page
String strResult;
WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create(strURL);
objResponse = objRequest.GetResponse(); // the using keyword will automatically dispose the object // once complete using (StreamReader sr =
new StreamReader(objResponse.GetResponseStream()))
{
strResult = sr.ReadToEnd(); // Close and clean up the StreamReader
sr.Close();
} return strResult;
}
Also you can use XmlTextReader which might be a bit simple:
// Create the XmlReader object.
XmlTextReader reader = new XmlTextReader("http://msdn.microsoft.com/rss.xml");
XmlDocument doc = new XmlDocument();
doc.Load(reader);
reader.Close();
XmlNodeList nodes = doc.DocumentElement.SelectNodes("/rss/channel/item/title");
for (int i = 0; i < nodes.Count; i++)
{
Response.Write(nodes[i].Name + " value=");
Response.Write(nodes[i].FirstChild.Value);
Response.Write(("
"));
}
You can add minor changes to above code to create dataset.
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.
Please feel free to let us know if there is any problem.
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.
Dim rd As XmlTextReader
Dim wrq As HttpWebRequest
wrq = WebRequest.Create("http://www.rediff.com/rss/inrss.xml")
wrq.Proxy = WebProxy.GetDefaultProxy
wrq.Proxy.Credentials = CredentialCache.DefaultCredentials
rd = New XmlTextReader(wrq.GetResponse.GetResponseStream)
can i read sourcefile of this webpage in my web application?
You can read any files in your disk,if not please check the fold permission.
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.
sachinvibhut...
Member
315 Points
81 Posts
"The remote server returned an error: (407) Proxy Authentication Required" Help please
Mar 15, 2007 09:49 AM|LINK
Friends
I am trying to use rss feed from news web site in my web application. and code i have written for tht is
string path = "http://msdn.microsoft.com/rss.xml"; //"D:\\WebSite\\master pages\\XMLFile.xml" DataSet ds = new DataSet();ds.ReadXml(path);
DataList1.DataSource = ds.Tables[
"item"];DataList1.DataBind();
but when i run the application i get the error message asThe remote server returned an error: (407) Proxy Authentication Required.
please help me.[*-)]
Sohnee
Contributor
2560 Points
492 Posts
Re: "The remote server returned an error: (407) Proxy Authentication Required" Help please
Mar 15, 2007 12:00 PM|LINK
You might want to use a HttpWebRequest to get the page (in conjunction with a StreamReader) before reading it into the dataset.
public String GetPage(string strURL)
{
// the html retrieved from the page
String strResult;
WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create(strURL);
objResponse = objRequest.GetResponse();
// the using keyword will automatically dispose the object
// once complete
using (StreamReader sr =
new StreamReader(objResponse.GetResponseStream()))
{
strResult = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
return strResult;
}
Young Fang -...
All-Star
17147 Points
1620 Posts
Re: "The remote server returned an error: (407) Proxy Authentication Required" Help please
Mar 16, 2007 01:47 AM|LINK
Hi,
Also you can use XmlTextReader which might be a bit simple:
// Create the XmlReader object. XmlTextReader reader = new XmlTextReader("http://msdn.microsoft.com/rss.xml"); XmlDocument doc = new XmlDocument(); doc.Load(reader); reader.Close(); XmlNodeList nodes = doc.DocumentElement.SelectNodes("/rss/channel/item/title"); for (int i = 0; i < nodes.Count; i++) { Response.Write(nodes[i].Name + " value="); Response.Write(nodes[i].FirstChild.Value); Response.Write(("You can add minor changes to above code to create dataset.")); }
__________________________________________________
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.
sachinvibhut...
Member
315 Points
81 Posts
Re: "The remote server returned an error: (407) Proxy Authentication Required" Help please
Mar 21, 2007 10:06 AM|LINK
Hi sohnee
sorry for replying after so long time.
i used the code u hv suggested bt this time it gives me the error message
The remote server returned an error: (404) Not Found.
the web address i am accessing now is "
http://www.rediff.com/rss/inrss.xml" when access it frim ie i can see tht page bt why it is not accessible in my application
do u think tht after hosting the site it wont cause me any problem?
please help..![*-)]
sachinvibhut...
Member
315 Points
81 Posts
Re: "The remote server returned an error: (407) Proxy Authentication Required" Help please
Mar 21, 2007 10:26 AM|LINK
hi Young Fang
thanks for reply will u plz gv me some links from where i can get complete reference for ASP.NET 2.0 framework.
thanks
Young Fang -...
All-Star
17147 Points
1620 Posts
Re: "The remote server returned an error: (407) Proxy Authentication Required" Help please
Mar 22, 2007 02:30 AM|LINK
You can take a look at Tutorials on How to Start Learning ASP.NET.
For you problem please try following code:
// Create the XmlReader object.
XmlTextReader reader = new XmlTextReader("http://www.rediff.com/rss/inrss.xml");
dataset.ReadXml(reader);
reader.Close();
Please feel free to let us know if there is any problem.
__________________________________________________
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.
sachinvibhut...
Member
315 Points
81 Posts
Re: "The remote server returned an error: (407) Proxy Authentication Required" Help please
Mar 22, 2007 05:41 AM|LINK
hi Young Fang
i tried the code u suggested but now i am getting this error
The remote server returned an error: (404) Not Found.
though resource http://www.rediff.com/rss/inrss.xml is existing.
will u please tell me why it is giving this error?
can i read sourcefile of this webpage in my web application?
i think if it is possible then it will help me out
please help![Yes]
Young Fang -...
All-Star
17147 Points
1620 Posts
Re: "The remote server returned an error: (407) Proxy Authentication Required" Help please
Mar 22, 2007 06:55 AM|LINK
Hi,
I tested and it works fine on my pc.
You'd better check the firewall and proxy.
If you are behind a proxy server please try this:
Dim rd As XmlTextReader Dim wrq As HttpWebRequest wrq = WebRequest.Create("http://www.rediff.com/rss/inrss.xml") wrq.Proxy = WebProxy.GetDefaultProxy wrq.Proxy.Credentials = CredentialCache.DefaultCredentials rd = New XmlTextReader(wrq.GetResponse.GetResponseStream)You can read any files in your disk,if not please check the fold permission.
__________________________________________________
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.
sachinvibhut...
Member
315 Points
81 Posts
Re: "The remote server returned an error: (407) Proxy Authentication Required" Help please
Mar 22, 2007 09:41 AM|LINK
hi Young Fang
u r great. Its working now.
Thank u very much for help.[:D][Yes]
sachinvibhut...
Member
315 Points
81 Posts
Re: "The remote server returned an error: (407) Proxy Authentication Required" Help please
Mar 22, 2007 09:42 AM|LINK
hi Young Fang
u r great. Its working now.
Thank u very much for help.[:D][Yes]