2012-10-05 4 views
0

ABCPDF.net을 사용하여 HTML을 PDF 페이지로 렌더링하고 있지만 현재 인증 된 세션을 사용하여이를 보호하려고합니다. 그러나 PDF를 렌더링하기 위해 HTML을 가져 오라는 요청은 세션을 수행하지 않지만 새로운 것을 생성합니다. ASP.NET 멤버쉽을 사용하고 있으며 세션 ID를 passwigin하고 ASP.NET 요청에 대한 쿠키를 만듭니다.ASP.NET의 다른 요청에 인증 된 세션 전달

var sessionId = HttpUtility.ParseQueryString(Url)["sid"]; 

    if(sessionId != null) 
    { 
     doc.HtmlOptions.HttpAdditionalHeaders = string.Format("Cookie: 
            ASP.NET_SessionId={0}", sessionId); 
    } 

나는 이것을 ABCPDF.net 문서에서 읽었지만 그 일을하고 있지만 요청은 항상 다른 세션을 사용합니다.

httpadditionalheaders

내가 뭔가를 통과해야합니까, 아니면 다른 뭔가를 할 수 있습니까?

답변

1

URL에 인증 쿠키를 보내고 쿠키를 업데이트하여 문제를 해결했습니다.

URL이 호출 방법

Url.ActionAbsolute(MVC.Events.Pools(eventId).AddRouteValue(FormsAuthentication.FormsCookieName, Request.Cookies[FormsAuthentication.FormsCookieName].Value) 

Global.asax에

protected void Application_BeginRequest() 
     { 
      try 
      { 
       string auth_cookie_name = FormsAuthentication.FormsCookieName; 

       if (HttpContext.Current.Request.Form[FormsAuthentication.FormsCookieName] != null) 
       { 
        UpdateCookie(auth_cookie_name, HttpContext.Current.Request.Form[FormsAuthentication.FormsCookieName]); 
       } 
       else if (HttpContext.Current.Request.QueryString[FormsAuthentication.FormsCookieName] != null) 
       { 
        UpdateCookie(auth_cookie_name, HttpContext.Current.Request.QueryString[FormsAuthentication.FormsCookieName]); 
       } 

      } 
      catch 
      { 
      } 
     } 

     void UpdateCookie(string cookieName, string cookieValue) 
     { 
      HttpCookie cookie = HttpContext.Current.Request.Cookies.Get(cookieName); 
      if (cookie == null) 
      { 
       cookie = new HttpCookie(cookieName); 
       HttpContext.Current.Request.Cookies.Add(cookie); 
      } 
      cookie.Value = cookieValue; 
      HttpContext.Current.Request.Cookies.Set(cookie); 

    }