1
WebImage.Write() 응답을 가진 MVC 작업에 OutputCache를 추가하려고하는데 (0의 지속 시간에도 불구하고) 콘텐츠 유형이 image/jpeg에서 text/html로 변경되고 브라우저에서 텍스트로 렌더링 된 이미지가 표시됩니다.MVC WebImage OutputCache 결과 텍스트/html 형식의 콘텐츠 형식
샘플 코드 -이는 OutputCache를 속성이 제거되면 제대로 작동 :
[OutputCache(Duration = 3000)]
public void GetImage(Guid id)
{
//Create WebImage from byte[] stored in DB
DbImage image = DbImageDAL.SelectSingle(e => e.DbImageId == id);
WebImage webimage = new WebImage(image.Data);
webImage.Write();
//Tried webImage.Write("JPEG"); but it makes not difference
}
감사합니다. @Pete that 's perfect! – Rob
보다 일반적인 버전의 경우 base.OnResultExecuting 호출 전에 ContentType의 현재 값을 저장 한 다음 끝에 다시 설정할 수 있습니다. – Mog0