今天做一個(gè)vb.net的登錄實(shí)例,前臺(tái)使用Ext中Ajax ,后臺(tái)用ashx文件處理登錄過(guò)程,并將用戶儲(chǔ)存在Session中總是出現(xiàn)在這個(gè)錯(cuò)誤. [NullReferenceException: 未將對(duì)象引用設(shè)置到對(duì)象的實(shí)例。]
.................
原來(lái):在 ashx 中要使用Session ,需要繼承System.Web.SessionState.IRequiresSessionState接口.默認(rèn)的之繼承了IHttpHandler接口
%@ WebHandler Language="VB" Class="logout" %>
Imports System
Imports System.Web
Imports System.Web.SessionState
Public Class logout : Implements IHttpHandler, IRequiresSessionState
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
context.Session.Clear()
context.Response.Write("{'success':'true'}") 'JSON格式數(shù)據(jù)
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class