Demopublic ActionResult File()
{
string fileName = "~/Content/test.zip"; // 文件名
string downFileName = "文件显示名称.zip"; // 要在下载框显示的文件名
return File(fileName, "application/octet-stream", downFileName);

http://hi.baidu.com/shishengli1234/item/e6b093c9ac024ed69744521f

解决方案 »

  1.   

     http://blog.csdn.net/xxhm0867/article/details/8023457
      

  2.   

    你可以把id放在session中,客户端再发起一次连接获取。 
      

  3.   

    两个路由不一样,如果在 /Account/Login 中,用 viewdata 等 都可以。
    现在路由是 /Account/GetValidateCode,在这里赋值后,前台无法获取viewdata的参数
      

  4.   

     
    public dynamic GetValidateCode()
            {
                string id = "1";//如何把 id 也返回去,并在前台如何获取
     
                ......
                byte[] bs = (byte[])cc.CaptchaImage;
                return File(bs, @"image/jpeg");
            }public dynamic GetValidateCode()
            {
              
                return "给分吧";
            }
      

  5.   

    谢谢大家!
    大家说的方法,在同一个路由中是没问题的。
    现在view调用的是另一个路由 /Account/GetValidateCode ,导致了获取这些变量为 null还有 jhl52771 您用动态的,在view 要怎么调用