调用aspx页面时,Request.Form.Count为0

时间:2017-09-27 07:24:58

标签: c# html asp.net post

我试图使用下面的表单发布到aspx页面是代码。值正在进行,但request.form.count为'0'。因此,我无法在请求的页面中调用方法。这适用于本地主机,但不适用于iis。

protected void FormPost(string Token)
{
    NameValueCollection collections = new NameValueCollection();
    collections.Add("Token", Token);
    string remoteUrl = hdnURL.Value;
    string html = "<html><head>";
    html += "</head><body onload='document.forms[0].submit()'>";
    html += string.Format("<form name='PostForm' method='POST' action='{0}'>", remoteUrl);
    foreach (string key in collections.Keys)
    {
        html += string.Format("<input name='{0}' type='hidden' value='{1}'>", key, collections[key]);
    }
    html += "</form></body></html>";
    Response.Clear();
    Response.ContentEncoding = Encoding.GetEncoding("ISO-8859-1");
    Response.HeaderEncoding = Encoding.GetEncoding("ISO-8859-1");
    Response.Charset = "ISO-8859-1";
    Response.Write(html);
    Response.End();
}

0 个答案:

没有答案