When ASP. net mvc 3 RC2 is usedCodeIn some cases, the correct results are always not returned (this is also possible in the first few versions ):
Memorystream MS = Xxxx; // Image Type
Return File (MS, " Image/JPEG " );
After tracking the file results, there is indeed data, but it cannot be returned on the page (in this case, the file rewrite method returns filesreamresult ).
However, if you save the stream as a file and then directly return the file name, you can:
Return File (filename, " Image/JPEG " );
In this case, filecontentresult is returned by the file Rewriting Method.
After comparison, we found that both methods can obtain the correct filesreamresult or filecontentresult, but MVC cannot render filesreamresult correctly, so walkaround:
Memorystream MS = Xxxx; // Image Type
Return File (Ms. toarray (), " Image/JPEG " );
In this way, the memorystream is converted to the byte [] type, and the returned type is filecontentresult, which can be output normally.