1. SharePoint내에서 사용할 세션을 만드는 방법을 설명합니다. 근데 이번에 특이하게 비하인드 코드에서 처리하지 않고 Client Script단에서 처리하는 것을 설명하도록 하겠습니다.
2. 우선 Web.Config에다 세션 사용을 활성화합니다.
a. enableSessionState를 true로 만듭니다.
b. <remove name="Session" />을 주석 처리합니다.
3. 이제 SharePoint에서 Session 사용할 위치(예를 들어, 초기 접속페이지 또는 상단 Top Web Part 등)에다 아래와 같이 페이지 로딩 시, 시작할 스크립트를 만듭니다.
<script type ="text/javascript">
$(document).ready(function () {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
data: '{"Session_TYPE":"' + target + '"}',
url: "/_layouts/15/OutofBox/WSSvc.aspx/Session",
dataType: "json",
success: function (data) {
//$("#Session_Message").html(data);
}
});
});
</script>
4. SharePoint Layout Page를 '/_layouts/15/OutofBox/WSSvc.aspx' 이 경로에 만듭니다. 그리고 아래와 같이 WebMethod를 추가합니다.
[WebMethod]
public static void Session(string SESSION_TYPE)
{
HttpContext.Current.Session["SESSIONTYPE"] = SESSION_TYPE;
HttpContext.Current.Session.Timeout = 60;
}
5. 이제 세션 생성이 완료되었습니다. 이렇게 생성된 세션은 아래와 같이 사용할 수가 있습니다.
If(HttpContext.Current.Session["SESSIONTYPE"] != null)
{
코딩…...
'SharePoint 2013' 카테고리의 다른 글
Workflow 개발(SharePoint Designer 2013) (0) | 2013.10.08 |
---|---|
PowerPivot for SharePoint 2013 구성방법 (0) | 2013.06.05 |
ComboBox 동적구현하기(JQuery 사용) (0) | 2013.04.08 |
HttpContext.Current.Session 사용방법 (0) | 2013.04.03 |
SharePoint 2013에서 Reporting Service 구축하기 (0) | 2013.03.19 |