WebForms에서 Response.Cache.SetCacheability
을 어떻게 호출합니까?ASP.net WebForms에서 Response.Cache.SetCacheability를 설정하는 방법은 무엇입니까?
은 MSDN의 How to: Set a Page's Cacheability Programmatically 보면 :
는 Response 개체의 Cache 특성에 SetCacheability 메소드를 호출 페이지의 코드에서 페이지의 캐시 가능성 프로그래밍
을 설정합니다.
다음 코드는 캐시 제어 HTTP 헤더를 Public으로 설정합니다.
Response.Cache.SetCacheability(HttpCacheability.Public);
좋아. 우수한. 좋은. 어떻게해야합니까?
protected void Page_Init(object sender, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.Public); //Public, while we test this
}
그러나 서버에서 응답하지 공개되지 않습니다 (사실 개인입니다) : : 시도에서
후 Page_Init 이벤트 핸들러에 추가
HTTP/1.1 200 OK
Server: ASP.NET Development Server/11.0.0.0
Date: Fri, 11 Jul 2014 14:11:06 GMT
X-AspNet-Version: 4.0.30319
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 9382
Connection: Close
그래서 내 코드가 작동하는지 확인하고 싶습니다. 따라서 더미 헤더를 추가하십시오 :
protected void Page_Init(object sender, EventArgs e)
{
//Response.Headers.Add("X-Hello-Before", "WhyArentYouWorking");
Response.AddHeader("X-Hello-Before", "WhyArentYouWorking");
Response.Cache.SetCacheability(HttpCacheability.Public); //Client is allowed to cache
//Response.Headers.Add("X-Hello-After", "MyGodYouSuck");
Response.AddHeader("X-Hello-After", "MyGodYouSuck");
}
과 항목은 응답 헤더에 나타납니다
HTTP/1.1 200 OK
Server: ASP.NET Development Server/11.0.0.0
Date: Fri, 11 Jul 2014 14:16:47 GMT
X-AspNet-Version: 4.0.30319
X-Hello-Before: WhyArentYouWorking
X-Hello-After: MyGodYouSuck
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 9382
Connection: Close
질문은 :
어떻게 나는 그것이 무엇을 말할 ASP.net 어떻게해야합니까?
어디서 버그인지 알 수 없습니다. 그것은 ASP.net에있을 수 있습니다. 그것은 WebForms에있을 수 있습니다. .NET Framework 4.0에있을 수 있습니다. 카시 니에있을 수 있습니다.