출처 : http://blog.naver.com/PostView.nhn?blogId=inidu2&logNo=110077631974&categoryNo=0&parentCategoryNo=33&viewDate=¤tPage=2&postListTopCurrentPage=1&userTopListOpen=true&userTopListCount=10&userTopListManageOpen=false&userTopListCurrentPage=2
닷넷에서 jquery를 사용 $.post() 사용하여 ajax로 처리를 하는데 ashx에서 세션 생성이 안되고 읽기만 가능하도록 되어 있어서 한참 동안 삽질.
네이년에도 안나와서 구글 찾아보니 나온다.
A reminder to myself and others, when you want to get access to your Session State from an ASHX or HttpHandler, you need to implement IReadOnlySessionState:
<% @ webhandler language="C#" class="DownloadHandler" %>
using System;
using System.Web;
using System.Web.SessionState;public class DownloadHandler : IHttpHandler, IReadOnlySessionState
{
public bool IsReusable { get { return true; } }
public void ProcessRequest(HttpContext ctx)
{
ctx.Response.Write(ctx.Session["fred"]);
}
}
세션을 사용하려면 IReadOnlySessionState, IRequiresSessionState 를 써야 한다.
원문 : http://www.hanselman.com/blog/GettingSessionStateInHttpHandlersASHXFiles.aspx
'PP > AJAX' 카테고리의 다른 글
AJAX + JSON + ASMX & ASHX (0) | 2012.01.07 |
---|---|
jQuery로 Asp.Net Ajax 사용하기 (Page Method와 Web Service 호출) (0) | 2012.01.07 |
jQuery를 사용하여 ASP.NET AJAX Web Service 호출하기 예제 (0) | 2012.01.07 |
DataSet <-> Json 파일 (Newtonsoft JSON.NET / JavaScriptSerializer) (0) | 2012.01.04 |
JQUERY WITH JSON (0) | 2012.01.04 |