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();
}
mvc 3에서 작업을 무시합니까? –
나는 그것을했다. .. 그러나 그것은 작동하지 않는다. –
@ Freetalk13 오버라이드는 .Net의 특징이지 MVC가 아니다. C#의 모든 버전에서 사용할 수 있습니다. –