2014-10-08 2 views
0

온라인 양식으로 작동하지만 Internet Explorer, Firefox 및 Chrome의 개발 환경에서는 작동하지 않는 것으로 보이는 ASP.NET 양식 인증을 사용합니다. 지금까지 내가 페이지가 요청 될 때 IIS가 Set-Cookie HTTP 헤더를 전송하지 볼 수 있습니다 : 나는 \Windows\System32\drivers\etc\hosts 파일에 127.0.0.1 www.example.com을 추가하는 대신 http://www.example.com:81에 접근하지만, 그 효과가 없습니다 해봤HTTP 헤더의 IIS가 쿠키를 설정하지 않습니다.

GET http://127.0.0.1:81/ HTTP/1.1 
Accept: text/html, application/xhtml+xml, */* 
Accept-Language: nb-NO 
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko 
Accept-Encoding: gzip, deflate 
Host: 127.0.0.1:81 
DNT: 1 
Connection: Keep-Alive 

HTTP/1.1 200 OK 
Cache-Control: private 
Content-Type: text/html; charset=utf-8 
Vary: Accept-Encoding 
Server: Microsoft-IIS/8.0 
X-AspNet-Version: 4.0.30319 
X-Powered-By: ASP.NET 
Date: Wed, 08 Oct 2014 19:24:58 GMT 
Content-Length: 13322 

. 여기 내 Web.config의 설정입니다 : 내가 찾은

<!-- ASP.NET forms authentication is enabled by default --> 
<authentication mode="Forms"> 
    <!-- Set the page to redirect to when the user attempts to access a restricted resource --> 
    <forms loginUrl="~/Account/Login.aspx" timeout="2880" /> 
</authentication> 

답변

0

는 작업 주위에 쿠키가 ASP.NET 웹 페이지 내부에 전송되지 않은 경우 항상 더미 쿠키를 설정하여 :

/// <summary> 
/// Force the browser to use cookies if none are in use. 
/// Sets an empty cookie. 
/// </summary> 
void ForceCookiesIfRequired() 
{ 
    if (Request.Cookies == null || Request.Cookies.Count == 0) 
    { 
     // No cookies, so set a dummy blank one 
     var cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, String.Empty) { Expires = DateTime.Now.AddYears(-1) }; 
     Response.Cookies.Add(cookie1); 
    } 
} 

protected override void OnInit(EventArgs e) 
{ 
    base.OnInit(e); 

    // Force the use of cookies if none are sent 
    ForceCookiesIfRequired(); 
} 

I 이전에는이 ​​작업을 수행하지 않았으며 일부 Microsoft 패치 또는 업그레이드 된 ASP.NET 양식 인증을 업그레이드 한 적이 있습니까? 자신의 솔루션을 확인하는 한 가지 방법은 내가 추측하는 쿠키를 지우는 것입니다. 이렇게하면 HTTP 서버가 IIS 서버에 의해 전송되도록 Set-Cookie HTTP 헤더가 강제로 전송됩니다.

관련 문제