2011-12-12 3 views
0

MVC3 애플리케이션에서 데이터 집약적 인 작업이 발생했습니다. 성능 향상을 위해 다음과 같이 결과를 캐싱했습니다.컨트롤러에서 캐시 된 MVC3 캐시 된 액션 결과

[OutputCache(Duration=60,VaryByParam="none")] 
    public ActionResult Index(string server, string database) 
{ //get+display a list of objects 
} 

이 방법은 잘 작동합니다. 하지만 특정 작업이 Edit 또는 Create처럼 발생하면 캐시를 지우고 싶습니다.

[OutputCache(Location="Server", Duration=60,VaryByParam="none")] 
    public ActionResult Index(string server, string database) 
: 내가 캐시 삭제 실제로 다음과 같이 작동하도록 서버에서 작업을 캐시 할 때 How to programmatically clear outputcache for controller action method

하지만을 : 나는 다음이

var urlToRemove = Url.Action("HtmlOutputMethod", "Controller"); 
Response.RemoveOutputCacheItem(urlToRemove); 

을 수행하고있는 캐시를 지우려면

이 오류가 발생합니다 :

Cannot implicitly convert type 'string' to 'System.Web.UI.OutputCacheLocation'

MVC3에서이 기능이 사용되지 않습니까? 아니면 어셈블리가 누락 되었습니까? 이 모든 곳에서 사용되는 것을 볼 수 있지만 내 컴퓨터에서는 컴파일되지 않습니다. 이 사용 OutputCacheLocation을 말한다으로

답변

1

는 :

[OutputCache(Location=OutputCacheLocation.Server, Duration=60,VaryByParam="none")] 
public ActionResult Index(string server, string database) 

그리고 using이에서

추가 : 그것 뿐이다

using System.Web.UI; 
+0

합니다. 나는'System.Web.UI' 레퍼런스를 놓치고있었습니다. 감사 – Rondel