• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 346
  • Last Modified:

What is the best way to get a tiny string from a remote server?


I have a URL that shows UNIX date format. Something link this: 1192763425. The URL only contains this number, nothing extra.

I want to get this number into a string to use it in my C# desktop application.

What is the fastest and most efficient way to accomplish this task?

Please advise.
  • 2
1 Solution
Munawar HussainPrincipal Software EngineerCommented:
Though not sure if it is exactly what you want.
you can get contents of any site using httpRequest and httpResponse to specific URL
here is the way... thanks
using System;   
using System.IO;   
using System.Net;   
using System.Text;   
// Create the web request   
HttpWebRequest request = WebRequest.Create("http://www.mysite.com/") as HttpWebRequest;   
// Get response   
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)   
    // Get the response stream   
    StreamReader reader = new StreamReader(response.GetResponseStream());   
    // Console application output   

Open in new window

EEssamAuthor Commented:
It worked but as I stated I'm looking for the fastest and most efficient way. Why I do not use something like this:
string address = "http://www.somedomain.com/somefile.ext";
System.Net.WebClient client = new System.Net.WebClient ();
string reply = client.DownloadString (address);

Open in new window

Munawar HussainPrincipal Software EngineerCommented:
sure.. there are options.. but you need to select the one best match your requirements.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now