0

我正在尝试让 DevExpress 仪表控件在 MVC 中工作。实际教程在这里: http: //www.devexpress.com/Support/Center/p/E2976.aspx。它通过 xml 文件创建设置并构建图像,然后将其存储在控制器的内存流中并推送到位于视图上的 img 标签。这个 img tags src attr 正在调用 Url.Action 来调用动作来渲染 Gauge。控制器中的代码如下所示

[OutputCache(Duration = 1000, VaryByParam = "param")]
        public ActionResult RenderGauge(double param)
        {
            ASPxGaugeControl ctrl = new ASPxGaugeControl();
            param = param * 100;
            ctrl.RestoreLayoutFromXml(Server.MapPath("~/App_Data/gauge.xml"));
            (ctrl.Gauges["myGauge"] as CircularGauge).Scales["myScale"].Value = (float)param;

            MemoryStream stream = new MemoryStream();
            ctrl.ExportToImage(stream, ImageFormat.Jpeg);

            stream.Seek(0, SeekOrigin.Begin);
            return new FileStreamResult(stream, "image/jpeg");
        }

视图如下所示:

<div style="background: 1px solid Blue; width; 240px;">
<%  double data = Model.ListData[0].Percentage; %>
                    <img src='<%: Url.Action("RenderGauge", "GetDashBoard", new RouteValueDictionary(new { param = data })) %>'
                        alt="Gauge showing data" id="gaugeImg1" />

    </div>

同样,这一切都在我的本地机器上工作,但在服务器上呕吐。src attr 似乎渲染得很好:

<img src='/CINet/CorporateDashBoard/GetDashBoard/RenderGauge?param=0.7'
                        alt="Gauge showing data" id="gaugeImg1" />

我还想补充一点,这是 IIS 7、MVC 2,我尝试添加在 Internet 上找到的特殊处理程序但没有成功:

<handlers>
      <add type="DevExpress.Web.ASPxUploadControl.ASPxUploadProgressHttpHandler, DevExpress.Web.v11.2, Version=11.2.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET,POST" path="ASPxUploadProgressHandlerPage.ashx" name="ASPxUploadProgressHandler" preCondition="integratedMode" />
      <add name="PNG Images" path="*.png" verb="*" type="System.Web.StaticFileHandler" resourceType="Unspecified" preCondition="integratedMode" />
 </handlers>

Any help would be greatly appreciated!

4

1 回答 1

0

Thank you everyone for your questions, it was weird because it never puked and going directly there yielded the same results of the 'x' and alt text being displayed but no image. Turned out to be that the Gauge dll for DevExpress was not being copied locally on the server. Would have thought I would have gotten a complaining exception for that, but oh well. Hope this helps others

于 2012-06-29T14:18:04.880 回答