【问题标题】:Stream a blob image through a XML / XSLT process通过 XML/XSLT 进程流式传输 blob 图像
【发布时间】:2013-09-13 02:34:51
【问题描述】:

我正在尝试在 C# ASP.NET 项目中使用 XML / XSLT 技术显示来自数据库的图像。这是一个代码示例,展示了我如何使用 XSLT。

/// <summary>
/// Get HTML form xml 
/// </summary>
/// <param name="xsltPath">the path to the xsl stylesheet</param>
/// <param name="xml">contain the xml</param>
/// <returns>the html</returns>
public string GetHtmlFrom_XML_XSL(string xsltPath, string xml) 
{
    xml = this.CleanString(xml);
    MemoryStream stream = new MemoryStream(ASCIIEncoding.UTF8.GetBytes(xml));
    XPathDocument document = new XPathDocument(stream);
    StringWriter writer = new StringWriter();
    XslCompiledTransform transform = new XslCompiledTransform();
    transform.Load(xsltPath);
    transform.Transform(document, null, writer);
    return writer.ToString();
}

我现在必须在 SQL 服务器中显示来自 blob 的图像...我不知道该怎么做。我尝试在这样的 xsl 表中使用 .ashx 处理程序:

    <img height="150" width="120">
      <xsl:attribute name="src">~/ImageHandler.ashx?atoContactId=<xsl:value-of select="owner/picture" /></xsl:attribute>
      <xsl:attribute name="alt">
        <xsl:value-of select="owner/name" />
      </xsl:attribute>
    </img>

当然,XSLT产生的html是在浏览器中流式传输的,src属性的请求HTTP没有处理。这会产生一个空图像(红十字)。

有什么方法可以工作,或者我应该忘记 XML / XSLT 来显示 blob 图像?

【问题讨论】:

  • “在浏览器中流式传输”是什么意思?你当前的输出是什么,它有什么问题?
  • 例如,您的 MemoryStreamStringWriter 周围应该有 using 块。

标签: c# xml image xslt


【解决方案1】:

Herehere 是答案,如何从 sql server 读取 blob。

一般来说,你必须先从 sql server 读取图像。然后你可以使用任何你想在页面上显示的技术。

【讨论】:

  • 事实上这正是我所做的。 http:/AnyWebserverThatGetTheImageFromDB.com 谢谢 :)
猜你喜欢
  • 2014-11-22
  • 1970-01-01
  • 2017-10-27
  • 1970-01-01
  • 2021-11-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多