3

i am new to asp.net,

ı want to get data from url on asp.net. & need data to be in store into string.

if suppose this is my URL thn i want to fetch this URL Data in string,

http://www.islamicfinder.org/prayer_service.php?country=bahrain&city=manama&state=02&zipcode=&latitude=26.2361&longitude=50.5831&timezone=3.00&HanfiShafi=1&pmethod=4&fajrTwilight1=&fajrTwilight2=&ishaTwilight=0&ishaInterval=0&dhuhrInterval=1&maghribInterval=1&dayLight=0&simpleFormat=xml
0

2 Answers 2

6

Try this

string url = "http://www.islamicfinder.org/prayer_service.php?country=bahrain&city=manama&state=02&zipcode=&latitude=26.2361&longitude=50.5831&timezone=3.00&HanfiShafi=1&pmethod=4&fajrTwilight1=&fajrTwilight2=&ishaTwilight=0&ishaInterval=0&dhuhrInterval=1&maghribInterval=1&dayLight=0&simpleFormat=xml";
            var webClient = new WebClient();
            string data = webClient.DownloadString(url);
Sign up to request clarification or add additional context in comments.

7 Comments

i want to store this data into my table, how should i, do this ?
@krunal It depends on a lot of things. What database are you using? what data access technology?
i am not using any db, i just want to store this data in my HTML TABLE.. how should i, do this ?
@krunal you'll need to provide more info on how you want the table formated. is the table already on the page? pls edit your question to enable me answer accurately or create a new question and paste the link here.
i want to fetch data from this url "ipad.idealake.com/default.aspx?id=G" and i want to display this data in my HTML Table.. i tried this ("geekswithblogs.net/dotNETvinz/archive/2009/06/24/…) code but it shows me error in form1.
|
2

WebClient is useful for this kind of thing (scartag's answer demonstrates the simplicity of this), but for more advanced options you should look at the underlying WebRequest class:

// Create a request for the URL.        
WebRequest request = WebRequest.Create ("http://www.contoso.com/default.html");

// If required by the server, set the credentials.
request.Credentials = CredentialCache.DefaultCredentials;

// Get the response.
HttpWebResponse response = (HttpWebResponse)request.GetResponse ();

// Display the status.
Console.WriteLine (response.StatusDescription);

// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream ();

// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader (dataStream);

// Read the content.
string responseFromServer = reader.ReadToEnd ();

// Display the content.
Console.WriteLine (responseFromServer);

// Cleanup the streams and the response.
reader.Close ();
dataStream.Close ();
response.Close ();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.