Asp.net mvc 3 MVC3处理程序.ashx

Asp.net mvc 3 MVC3处理程序.ashx,asp.net-mvc-3,handler,Asp.net Mvc 3,Handler,您好,我正在从ActionResult调用Handler.ashx ViewBag.IMG = "Handler.ashx?img=" + imagetest + ,如果ActionResult是Index,则其工作正常 http://localhost:11111/ImageHandler.ashx?img=image 但是,如果它是任何其他名称,它不会调用处理程序 http://localhost:11111/ActionReult(name)/ImageHandler.ashx?im

您好,我正在从ActionResult调用Handler.ashx

 ViewBag.IMG = "Handler.ashx?img=" + imagetest +
,如果ActionResult是Index,则其工作正常

http://localhost:11111/ImageHandler.ashx?img=image
但是,如果它是任何其他名称,它不会调用处理程序

http://localhost:11111/ActionReult(name)/ImageHandler.ashx?img=image
它将ActionResult名称添加到url中


任何想法,请提前感谢。

那么我不理解false,.ashx可以使用控制器将FileContentResult或FileResult返回到文件,或将FileStreamResult返回到文件

样品

public FileContentResult Index()
{
    var Resim = new WebClient().DownloadData("https://dosyalar.blob.core.windows.net/dosya/kartalisveris.gif");
    return new FileContentResult(Resim, "image/png"); //* With {.FileDownloadName = "Höbölö"}
}

因此,通过变量公共

文件结果索引(字符串路径)

FileInfo-fi=newfileinfo(Server.MapPath(“~/Content/imgs/”)+picPath+ ”)


Url:File/Index/fillo_kargo.png

向我们展示代码……否则说发生了什么就像告诉机械师你的引擎出了什么问题,我发出声音。谢谢你的建议。
public FileResult Index()
{
    FileInfo fi = new FileInfo(Server.MapPath("~/Content/imgs/fillo_kargo.png"));
    return File(fi.OpenRead, "image/png"); //or .FileDownloadName("Eheheh :)") Return File(fi.OpenRead, "audio/mpeg","Media File")
}