有三点需要注意:
1.命名空间中要加入using System.Web.SessionState;
2.接口名要加入IRequiresSessionState或IReadOnlySessionState;
3.不管是Session还是QueryString都要通过HttpContext来获取。
具体代码如下:
01 |
<%@ WebHandler Language="C#" Class="UploadHandler" %> |
07 |
using System.Web.SessionState; |
09 |
public class UploadHandler : IHttpHandler, IRequiresSessionState |
12 |
public void ProcessRequest (HttpContext context) { |
13 |
context.Response.ContentType = "text/plain"; |
14 |
context.Response.Charset = "utf-8"; |
16 |
string str1 = context.Session["aaa"].ToString(); |
17 |
string str2 = context.Request.QueryString["bbb"].ToString(); |
20 |
public bool IsReusable { |