首页 新闻 会员 周边

webform webservice奇怪的问题

0
悬赏园豆:5 [已关闭问题] 关闭于 2013-04-21 21:47

偶遇一段神奇的代码。。这样写有什么作用呀??客户端用什么调用。。??怎样调用才能体现它的作用??WebForm1.aspx跟webservice在同一个站点上!

/// <summary>
    /// WebService1 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
    // [System.Web.Script.Services.ScriptService]
    public class WebService1 : System.Web.Services.WebService
    {
        [WebMethod]
        public void HelloWorld()
        {
            System.Web.HttpContext.Current.Response.Clear();
            StringBuilder strHTML = new StringBuilder();
            strHTML.Append("<html><head><title>发送</title>");
            strHTML.Append("</head><body onload=\"document.form1.submit()\">");
            strHTML.Append(string.Format("<form name=\"form1\" method=\"POST\" action=\"{0}\" >", "/WebForm1.aspx"));
            try
            {
                strHTML.Append(string.Format("<input name=\"Name\" type=\"hidden\" value=\"{0}\">", "JAMES"));
                strHTML.Append("</form>");
                strHTML.Append("</body></html>");
                System.Web.HttpContext.Current.Response.Write(strHTML.ToString());
                System.Web.HttpContext.Current.Response.End();
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write(ex.Message);
                HttpContext.Current.Response.End();
            }
        }
    }

KeVinDurant的主页 KeVinDurant | 初学一级 | 园豆:5
提问于:2013-04-19 21:49
< >
分享
所有回答(1)
0

http://www.cnblogs.com/thbbsky/archive/2013/04/21/3034008.html

曹县三胖暴打大猩猩 | 园豆:202 (菜鸟二级) | 2013-04-21 19:35
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册