' type="text/javascr-6ren">
gpt4 book ai didi

asp.net - 为什么我无法解析 css 文件的客户端 url?

转载 作者:行者123 更新时间:2023-12-04 00:47:23 26 4
gpt4 key购买 nike

这是我的 asp 代码:

<!-- language: lang-js -->
<head runat="server">
<title>
<asp:ContentPlaceHolder ID="TitleContent" runat="server" />
</title>
<link href='<%: ResolveClientUrl("~/Content/Site.css") %>' rel="stylesheet" type="text/css" />
<script src='<%: ResolveClientUrl("~/Scripts/jquery.js")%>' type="text/javascript" />
<script src='<%: ResolveClientUrl("~/Scripts/jquery-ui.js")%>' type="text/javascript" />
<link href='<%: ResolveClientUrl("~/Content/redmond/jquery-ui.css") %>' rel="stylesheet" type="text/css" class="ui-theme" />
</head>

这是呈现的 html:

<!-- language: lang-js -->
<head>
<title>Espace de travail</title>
<link href="&lt;%: ResolveClientUrl(&quot;~/Content/Site.css&quot;) %>" rel="stylesheet" type="text/css" />
<script src='Scripts/jquery.js' type="text/javascript"></script>
<script src='Scripts/jquery-ui.js' type="text/javascript"></script>
<link href="&lt;%: ResolveClientUrl(&quot;~/Content/redmond/jquery-ui.css&quot;) %>" rel="stylesheet" type="text/css" class="ui-theme" />
</head>

为什么 asp 可以解析我的 .js 脚本文件的 url 但不能解析我的 css 文件?

最佳答案

The URL returned by this method is relative to the folder containing the source file in which the control is instantiated .

改用 ResolveUrlUrl.Content 辅助方法。由于 head 标签上的 runat="server" 属性,第一个链接被编码。考虑删除属性或尝试 this solution .

关于asp.net - 为什么我无法解析 css 文件的客户端 url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6247481/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com