I am doing with static currency (AUD-->INR)
Place a button on _.aspx page. @ button click event do this..
protected void btnShow_Click(object sender, EventArgs e)
{
decimal apiRate = 0;
string firstCcode="AUD";
string lastCcode="INR"
decimal amount=1;
apiRate = ExchangeRateFromAPI(amount, firstCurrencyCode, currencyCode);
//use the apiRate;
}
private decimal ExchangeRateFromAPI(decimal amount,string firstCcode, string lastCcode)
{
try
{
WebClient web = new WebClient();
const string urlPattern = "http://finance.yahoo.com/d/quotes.csv?s={0}{1}=X&f=l1";
string url = String.Format(urlPattern, firstCcode, lastCcode);
// Get response as string
string response = new WebClient().DownloadString(url);
// Convert string to number
decimal exchangeRate = decimal.Parse(response, System.Globalization.CultureInfo.InvariantCulture);
return exchangeRate;
}
catch (Exception ex){
return 0;
}
}