하는 ASP.NET MVC3 액션 메소드 내부에서 IIS로 제어를 다시 반환 :이 메소드를 호출하는 URL의나는 즉시 축소판을 생성이 작업 방법이
public ActionResult Thumbnail(int imageId, int width, int height)
{
Image image = ImageManager.GetImage(imageId);
string thumbnailPath;
if (image.HasThumbnail(width, height))
{
thumbnailPath = image.GetThumbnailPath(width, height);
}
else
{
thumbnailPath = image.CreateThumbnail(width, height);
}
/*
Here, I've done the business of thumbnail creation,
now since it's only a static resource, I want to let IIS serve it.
What should I do? Using HttpContext.RewritePaht() doesn't work, as
I have to return an ActionResult here.
*/
return File(image.GetThumbnailPath(width, height), image.MimeType);
}
그리고 예 것은 :
/create-thumbnail/300x200/for-image/34
그러나이 방법으로 미리보기 이미지를 만든 후에는 IIS가 미리보기 이미지를 제공하도록하고 싶습니다. 어떻게해야합니까? 어떻게 컨트롤을 IIS로 되돌릴 수 있습니까?
? 사용자가 URL을 방문 할 때 파일 다운로드 프롬프트를 보길 원하십니까? –
'FileResult'를 반환하는 대신 IIS가 파일을 제공하길 원합니다. 그건 분명해 보인다. –