1.获取parmas方式:
public void ProcessRequest (HttpContext context) { ///跳转到一般处理程序的页面就自动运行的方法
context.Response.ContentType = "text/html";
string res=context.Request["name"]; //获取传递过来的name属性的值;
string path = context.Server.MapPath("HtmlPage.html"); //获取网页地址
context.Response.Write(System.IO.File.ReadAllText(path)); //读出本地址的内容,然后写出来。
context.Response.Write((string.IsNullOrEmpty(res)) ? "你是不是傻,这都不知道" : "哇,你好厉害哟");
}
2.使用formData的提交方式
context.Response.ContentType = "application/json";//返回json
//string Id = context.Request["Id"];//.Form["Id"];
string Id = context.Request.Form["Id"];
Common.ResultMsgWeb ResponseMsg = new Common.ResultMsgWeb(); ;
if (string.IsNullOrEmpty(Id))
{
ResponseMsg = GetLastNews(8);
}
else
{
ResponseMsg = GetOneNew(Id);
}
context.Response.Write(JsonConvert.SerializeObject(ResponseMsg));
3:地址栏获取参数:
context.Request.QueryString["RateAmount"].ToString().Trim();获取地址栏里的
context.Request.Params["RateAmount"].ToString().Trim();能获取多种类型的(地址栏,cookie),如有重复会报错
using System.Web.SessionState; context.Session["ws_user"].ToString() 获取session值;
4:获取链接全部参数
playerId = HttpUtility.UrlDecode(RequestStr.Request.Form["playerId"]).Trim();
ActivityId = HttpUtility.UrlDecode(RequestStr.Request.Form["ActivityId"]).Trim();
type = HttpUtility.UrlDecode(RequestStr.Request.Form["type"]).Trim();