我想使用HttpWebRequest GetResponse()方法调用一个动作方法。
我的代码是:
string url = http://localhost:1234/Test //Here "Test" is my action method
System.Net.HttpWebRequest objRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
objRequest.Method = "GET";
objRequest.ContentType = "application/x-www-form-urlencoded";
objRequest.AllowAutoRedirect = true;
objRequest.KeepAlive = false;
objRequest.Timeout = 300000;
using (System.Net.HttpWebResponse objResponse = (System.Net.HttpWebResponse)objRequest.GetResponse())
但它不起作用。我收到了以下错误。
它会抛出错误:
System.Net.WebException: The remote name could not be resolved: 'example.com' at System.Net.HttpWebRequest.GetResponse()
请帮忙。
谢谢。