在ashx中使用session
做一个网站,验证码用ashx输出,发现无法使用session,后来在网上搜了发现
原来要实现IRequiresSessionState接口
Imports System
Imports System.Web
Public Class Image : Implements IHttpHandler, IRequiresSessionState
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
context.Session("YourSession") = "SessionValue"
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
Imports System.Web
Public Class Image : Implements IHttpHandler, IRequiresSessionState
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
context.Session("YourSession") = "SessionValue"
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class