为什么 Spark viewengine 会呈现不必要的(或意外的)引号?

发布于 2024-08-16 08:37:20 字数 1474 浏览 3 评论 0原文

如果我在 web.config 中添加 pageBaseType="Spark.Web.Mvc.SparkView" (修复智能感知所必需的),不知何故,它不再正确渲染链接(可能不仅如此)。

这就是它应该的样子(如果未指定页面基本类型,则确实如此)=>

替代文本

这是指定基本类型时的样子=>

替代文本

Chrome 源查看器在两种情况下显示相同的页面源代码=>

<body> 
    <div class="content"> 
        <div class="navigation"> 
            <a href="/Employee/List">Employees</a> 
            <a href="/Product/List">Products</a> 
            <a href="/Store/List">Stores</a> 
            <div class="navigation_title"> 
                Navigation</div> 
        </div> 
        <div class="main"> 
            <div class="content"> 
<h2>Employees</h2>Nothing found...
&lt;a href=&quot;/Employee/Create&quot;&gt;Create&lt;/a&gt;           
            </div> 
        </div> 
    </div> 
</body> 

开发者工具没有=>

替代文本

那么 - 为什么我的链接会被 htmlencoded(如果发生这种情况)?如果这是默认行为,那么如何渲染原始 html?


使用最新的 Spark 版本,使用 Asp.Net Mvc2 RC 程序集重建。

If i add pageBaseType="Spark.Web.Mvc.SparkView" in my web.config (necessary to fix intellisense), somehow it does not render links (probably not only) correctly anymore.

This is how it's supposed to look like (and does, if page base type is not specified)=>

alt text

This is how it looks when base type is specified=>

alt text

Chrome source viewer shows identical page source code for both cases=>

<body> 
    <div class="content"> 
        <div class="navigation"> 
            <a href="/Employee/List">Employees</a> 
            <a href="/Product/List">Products</a> 
            <a href="/Store/List">Stores</a> 
            <div class="navigation_title"> 
                Navigation</div> 
        </div> 
        <div class="main"> 
            <div class="content"> 
<h2>Employees</h2>Nothing found...
<a href="/Employee/Create">Create</a>           
            </div> 
        </div> 
    </div> 
</body> 

Developer tools does not=>

alt text

So - why my link gets htmlencoded (if that's what happens)? If it's default behavior, then how to render raw html?


Using latest Spark version, rebuilt with Asp.Net Mvc2 RC assemblies.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤独难免 2024-08-23 08:37:20

web.config 中的automaticEncoding 设置为true 吗?

<spark>
  <pages automaticEncoding="false">
  </pages>
</spark>

is automaticEncoding set to true in the web.config?

<spark>
  <pages automaticEncoding="false">
  </pages>
</spark>
‖放下 2024-08-23 08:37:20

你这里有两个不同的问题。
首先是编码问题。
其次是引号,这些都是 Chrome 的。

Chrome 已将您的文本和链接包含在 CDATA 节点内。您的页面的某些内容触发了它呈现 XHTML,因此它不允许该文本出现在 DIV 中。通常,HTML 元素上的 XHTML 命名空间会执行此操作,或者您的应用程序正在发送具有 XHTML MIME 类型的页面。但我发现在 Chrome 中进行测试时,页面的其他内容会将其踢入 XHTML 模式,例如自结束标签等。

You have 2 different problems here.
First the encoding issue.
Second the Quotes, those are ALL Chrome.

Chrome has enclosed your text and link inside a CDATA node. Something about your page has triggered it to render XHTML and as such it won't allow that text inside a DIV. Usually the XHTML namespace on the HTML element does it or your app is sending pages with the XHTML MIME type. But I have found testing in Chrome that other things about a page will kick it into XHTML mode like self ending tags and the like.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文