当前位置:编程学习 > C#/ASP.NET >>

执行处理程序“System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper”的子请求时

执行处理程序“System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper”的子请求时出错。
InnerException:当使用自定义 TextWriter 时,OutputStream 不可用。

Controller中的代码如下:
public ActionResult FileContentResultDemo()
        {
            FileStream fs = new FileStream(Server.MapPath("~/Resources/a.jpg"), FileMode.Open, FileAccess.Read);
            byte[] buffer = new byte[Convert.ToInt32(fs.Length)];
            fs.Read(buffer, 0, Convert.ToInt32(fs.Length));
            return File(buffer, ".jpg");
        }

View中的代码如下:
    @Html.Action("FileContentResultDemo")    //报错

说明:这是一个MVC3程序。View中的@Html.Action("FileContentResultDemo")会报错。但是,如果使用如下链接的方式,就不会有问题了。
    @Html.ActionLink("跳转到FileContentResultDemo", "FileContentResultDemo")  //不报错

请问,大神们知道问题出在哪里麽? C#MVC3 ActionResult C# MVC3 ActionResult FileContentResult --------------------编程问答--------------------
引用 楼主 Anigado1992 的回复:
执行处理程序“System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper”的子请求时出错。
InnerException:当使用自定义 TextWriter 时,OutputStream 不可用。

Controller中的代码如下:
public ActionResult FileContentResultDemo()
        {
            FileStream fs = new FileStream(Server.MapPath("~/Resources/a.jpg"), FileMode.Open, FileAccess.Read);
            byte[] buffer = new byte[Convert.ToInt32(fs.Length)];
            fs.Read(buffer, 0, Convert.ToInt32(fs.Length));
            return File(buffer, ".jpg");
        }

View中的代码如下:
    @Html.Action("FileContentResultDemo")    //报错

说明:这是一个MVC3程序。View中的@Html.Action("FileContentResultDemo")会报错。但是,如果使用如下链接的方式,就不会有问题了。
    @Html.ActionLink("跳转到FileContentResultDemo", "FileContentResultDemo")  //不报错

请问,大神们知道问题出在哪里麽?


写法有误!
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,