货币不会转换ASP [英] Currency is not converting ASP
问题描述
我在asp.net中使用货币转换器,我正在尝试转换价值,但它显示错误plz建议。
我有什么试过:
当我点击转换按钮时显示远程服务器返回并出错(404)。
[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 (十进制金额, string fromCurrency, string toCurrency)
{
WebClient web = new WebClient();
// string url = string.Format(http://www.google.com/ig/计算器?hl = en& q = {2} {0}%3D%3F {1},fromCurrency.ToUpper(),toCurrency.ToUpper(),amount);
Uri uri = < span class =code-keyword> new Uri( string .Format( < span class =code-string> http://www.google.com/ig/calculator?hl=zh-CN&q= {2} {0}%3D%3F {1},fromCurrency。 ToUpper(),toCurrency.ToUpper(),amount));
string url = uri.AbsoluteUri + uri.Fragment;
string response = web.DownloadString(url);
正则表达式regex = 新正则表达式( rhs :\\\(\\d *。\\\\ *) );
匹配匹配= regex.Match(响应);
//十进制速率= System.Convert.ToDecimal(regex.Match(response).Groups [1] .Value);
decimal rate = System.Convert.ToDecimal(match.Groups [1] .Value);
return rate;
}
}
你请求的网址不存在,它可能在某一点上完成但不再存在。它们似乎已将它们的api移动到其他地方
货币转换器 - Google财经 [ ^ ]
引用:远程服务器返回错误(404)。
唯一的可能是你向远程服务器发送了错误的请求。 br />
建议:打印您的请求,看看它是否符合您的期望。
然后在浏览器中复制/粘贴,看看是否收到错误。
其他可能性,远程服务器可以防止滥用。
看起来像 http://www.google.com/ig/calculator [ ^ ]不存在。
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).
[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;
}
}
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[^]
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.
这篇关于货币不会转换ASP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!