2012-01-03 2 views
1

imagereult ..를 만들고 있지만 "public override void ExecuteResult (ControllerContext Context)"는 다음과 같이 말합니다.MVC 3 : CustomResult()가 적합한 메서드를 찾지 못했습니다.

내 클래스는 다음과 같습니다 ..

public override void ExecuteResult(ControllerContext Context) 
    { 
     byte[] bytes; 
     string contentType = GetContentTypeFromFile(); 

     //if there's no context, stop the processing 
     if (Context == null) 
     { 
      throw new ArgumentNullException("context"); 
     } 

     //check for file 
     if(File.Exists(_path)){ 
      bytes = File.ReadAllBytes(_path); 
     } 
     else{ 
      throw new FileNotFoundException(_path); 
     } 


     // 
     HttpResponseBase response = Context.HttpContext.Response; 
     response.ContentType = contentType; 

     MemoryStream imageStream = new MemoryStream(bytes); 

     byte[] buffer = new byte[4096]; 

     while (true) 
     { 
      int read = imageStream.Read(buffer, 0, buffer.Length); 

      if (read == 0) 
       break; 

      response.OutputStream.Write(buffer, 0, read); 
     } 

     response.End(); 

    } 

답변

0

이 클래스의 서브 클래스 ActionResult합니까? 다음을 시도해보십시오.

using System.Web.Mvc; 

public class ImageResult : ActionResult 
{ 
    public override void ExecuteResult(ControllerContext Context) 
    { 
    ... 
    } 
} 
+0

mvc 3에서 작업을 무시합니까? –

+0

나는 그것을했다. .. 그러나 그것은 작동하지 않는다. –

+0

@ Freetalk13 오버라이드는 .Net의 특징이지 MVC가 아니다. C#의 모든 버전에서 사용할 수 있습니다. –

관련 문제