Click here to Skip to main content
15,896,915 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am using currency converter in asp.net and i am trying to convert the value but it is showing error plz advice.

What I have tried:

WHEN I CLICK ON CONVERT BUTTON IT IS SHOWING "the remote server returned and error(404).

C#
[WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [ScriptService]
    public class WebService : System.Web.Services.WebService
    {
        [WebMethod]
        public decimal ConvertGOOG(decimal amount, string fromCurrency, string toCurrency)
        {
            WebClient web = new WebClient();
            //string url = string.Format("http://www.google.com/ig/calculator?hl=en&q={2}{0}%3D%3F{1}", fromCurrency.ToUpper(), toCurrency.ToUpper(), amount);
            Uri uri = new Uri(string.Format("http://www.google.com/ig/calculator?hl=en&q={2}{0}%3D%3F{1}", fromCurrency.ToUpper(), toCurrency.ToUpper(),amount));
            string url = uri.AbsoluteUri + uri.Fragment;
            string response = web.DownloadString(url);
            Regex regex = new Regex("rhs: \\\"(\\d*.\\d*)");
            Match match = regex.Match(response);
            //decimal rate = System.Convert.ToDecimal(regex.Match(response).Groups[1].Value);
            decimal rate = System.Convert.ToDecimal(match.Groups[1].Value);
            return rate;
        }
    }
Posted
Updated 5-May-16 3:05am
v2

The url you are requesting doesn't exist, it maybe did at one point but not any more. They seem to have moved their api to somewhere else

Currency Converter - Google Finance[^]
 
Share this answer
 
Quote:
the remote server returned and error(404).
The only possibility is that you send a wrong request to remote server.
Advice: print your request and see if it match your expectations.
Then copy/paste in your browser to see if you get the error.

Other possibility, the remote server can have protection against abuse.

Looks like "http://www.google.com/ig/calculator[^] doesn't exist.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900