![](/img/trans.png)
[英]changing directory of asp.net membership tables in visual studio 2012
[英]Visual Studio 2012 SP3 changing link href when using ASP.NET in design view
我正在使用VS 2012 SP3,其中我有一个ASP.NET网站。 在我的“Default.aspx”中,我有以下链接
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" runat="server" rel="stylesheet" />
每当我使用设计视图来为我的页面添加时,就像在表中插入新行一样
<link href="http://localhost:50309/netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" runat="server" rel="stylesheet" />
这变得非常烦人。
有没有人知道如何禁用此功能?
我还要注意,我已经安装了Productivity Power Tools 2012 Web Essentials 2012(但我已经禁用了它们,但仍然没有运气谢谢!
更新1: 重现的步骤
创建一个新的.aspx页面
在头标记之间粘贴<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" />
。
转到拆分视图
在div之间写一些文字
href变为<link href="http://localhost:50309/netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" />
(port可能会有所不同:D)
更新2: Microsoft Bug Report Connect Link
使用ASP.NET脚本包时,您可以提供可以找到脚本库的CDN位置。 当您还在本地添加代码时,您将获得能够针对非缩小版本进行调试的好处,而当站点在生产中运行时将使用CDN版本。
请参阅以下有关在ASP.NET Web窗体上设置脚本包的文档 。
基本上你需要在Global.asax中添加几行:
void Application_Start(object sender, EventArgs e)
{
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
然后按如下方式创建您的包:
public static void RegisterBundles(BundleCollection bundles)
{
//bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
// "~/Scripts/jquery-{version}.js"));
bundles.UseCdn = true; //enable CDN support
//add link to jquery on the CDN
var jqueryCdnPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js";
bundles.Add(new ScriptBundle("~/bundles/jquery",
jqueryCdnPath).Include(
"~/Scripts/jquery-{version}.js"));
// Code removed for clarity.
}
并像这样引用它:
<asp:PlaceHolder runat="server">
<%: Scripts.Render("~/bundles/modernizr") %>
<%: Scripts.Render("~/bundles/jquery") %>
<%: Scripts.Render("~/bundles/jqueryui") %>
</asp:PlaceHolder>
这应该取悦浏览器和编辑器。
您还可以使用以下代码配置<scriptmanager>
自动回退到CDN:
<asp:ScriptManager runat="server" EnableCdn="true">
<Scripts>
<asp:ScriptReference Name="jquery" />
<asp:ScriptReference Name="jquery.ui.combined" />
</Scripts>
</asp:ScriptManager>
而这个配置:
var mapping = ScriptManager.ScriptResourceMapping;
// Map jquery definition to the Google CDN
mapping.AddDefinition("jquery", new ScriptResourceDefinition
{
Path = "~/Scripts/jquery-2.0.0.min.js",
DebugPath = "~/Scripts/jquery-2.0.0.js",
CdnPath = "http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js",
CdnDebugPath = "https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.js",
CdnSupportsSecureConnection = true,
LoadSuccessExpression = "window.jQuery"
});
// Map jquery ui definition to the Google CDN
mapping.AddDefinition("jquery.ui.combined", new ScriptResourceDefinition
{
Path = "~/Scripts/jquery-ui-1.10.2.min.js",
DebugPath = "~/Scripts/jquery-ui-1.10.2.js",
CdnPath = "http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js",
CdnDebugPath = "http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.js",
CdnSupportsSecureConnection = true,
LoadSuccessExpression = "window.jQuery && window.jQuery.ui && window.jQuery.ui.version === '1.10.2'"
});
阅读Scott Hanselman撰写的以下博客, 了解更多详情 。
VS设计师对链接标记中的URI格式很挑剔,它会“修复”它不赞同的任何href。 结果并不总是有用。
在您的情况下,问题是您的href缺少方案名称。 如果您更改链接标记,VS应该停止重写您的href:
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" type="text/css" />
侧注:修复href后,设计人员可能会抱怨它无法编辑样式表。 我不知道为什么它使用这个特定的文件,我还没有看到它与其他CSS这样做。 只需忽略警告,就应该正确应用样式表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.