这是由于在IIS7中站点被以POST方式请求时,必须要求传递参数,如果调用的API无须传递参数,需要标记下内容为0
httpWebRequest.ContentLength = 0;
即可解决411异常.
#region 方法--动态调用InvokeWebService
/// <summary>
/// 指定Post地址使用Get 方式获取全部字符串
/// </summary>
/// <param name="url">请求后台地址</param>
/// <returns></returns>
public static string Post(string url)
{
string result = "";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentLength = 0;
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream stream = resp.GetResponseStrea