偶遇一段神奇的代码。。这样写有什么作用呀??客户端用什么调用。。??怎样调用才能体现它的作用??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();
}
}
}
http://www.cnblogs.com/thbbsky/archive/2013/04/21/3034008.html