ActionView下返回图片(验证码)

ActionView一般情况下返回的是视图,或者Json等,但是如果我要返回文件呢,比如说是验证码,其实 File(byte[],contenttype) 返回的就是 FileContentResult,其最终是继承自 ActionResult的,所以,下面是完整代码:

 

       public ActionResult Image(int width, int height)
        {                       
           return File(verification.CreateVerification(),"image/jpeg");              
         }

其中 

verification.CreateVerification()返回的是  byte[]。

posted on 2017-12-02 19:13  奔游浪子  阅读(57)  评论(0)    收藏  举报

导航