【问题标题】:The character '+' is converted into + in base64 encoded data字符 '+' 在 base64 编码数据中转换为 +
【发布时间】:2019-07-18 16:00:13
【问题描述】:

我正在尝试将从数据库检索到的图像附加到 D3.js 中我的力有向图中的节点中,如下所示:

var node = container.append("g").attr("class", "nodes")
            .selectAll("g")
            .data(nodes)
            .enter()
            .append("image")
            .attr("xlink:href", "data:image/jpeg;base64,@Convert.ToBase64String(photo)")
            .attr("x", -8)
            .attr("y", -8)
            .attr("width", 30)
            .attr("height", 30);

但是,我发现字符 + 被编码为 + 导致错误“无效 URL”。

正确的编码字符串:...3V1a+Z7p4m... 传递给函数后:...3V1a+Z7p4m...

谁能提供解决方案?

【问题讨论】:

  • 你试过@Html.Raw(...)
  • Daniel A. White 天哪,谢谢,这解决了问题!

标签: javascript c# razor


【解决方案1】:

Razor 正在进行一些编码。您必须将其更改为使用 @Html.Raw 以跳过编码。

【讨论】:

    猜你喜欢
    • 2019-02-16
    • 2011-09-17
    • 2012-11-12
    • 2018-08-05
    • 2014-04-08
    • 1970-01-01
    • 2014-12-03
    • 2020-07-25
    • 1970-01-01
    相关资源
    最近更新 更多