使用HttpWebRequest发布表单数据
我想将一些表单数据发布到不在我自己的Web应用程序内的指定URL中。它具有相同的域,例如“ domain.client.nl”。该Web应用程序有一个URL“ web.domain.client.nl”,我要发布到的URL是“ idp.domain.client.nl”。但是我的代码无能为力.....有人知道我在做什么错吗? 伍特 StringBuilder postData = new StringBuilder(); postData.Append(HttpUtility.UrlEncode(String.Format("username={0}&", uname))); postData.Append(HttpUtility.UrlEncode(String.Format("password={0}&", pword))); postData.Append(HttpUtility.UrlEncode(String.Format("url_success={0}&", urlSuccess))); postData.Append(HttpUtility.UrlEncode(String.Format("url_failed={0}", urlFailed))); ASCIIEncoding ascii = new ASCIIEncoding(); byte[] postBytes = ascii.GetBytes(postData.ToString()); // set up request object HttpWebRequest request; try { request = (HttpWebRequest)HttpWebRequest.Create(WebSiteConstants.UrlIdp); } catch (UriFormatException) { request = null; } if (request == …