ASP.NET ashx获取Url参数, 获取表单提交参数, 获取Get参数, 获取Post参数
Login.ashx页面中实现
using System.Web; namespace WebApplication5 { /// <summary> /// Login.ashx /// </summary> public class Login : IHttpHandler { public void ProcessRequest(HttpContext context) { // 获取Url参数, Get请求参数 // http://127.0.0.1/Default.ashx?id=1 string id = context.Request.QueryString["id"]; // 获取表单提交参数, Post请求参数 string username = context.Request.Form["username"]; // 为了防止有中文乱码的问题, 最好在获取时进行Url解码操作 username = System.Web.HttpUtility.UrlDecode(context.Request.Form["username"].ToString()); context.Response.ContentType = "text/plain"; context.Response.Write("UserName: " + username); } public bool IsReusable { get { return false; } } } }