我已经创建了新的MVC2 ViwUserControl,并在我的解决方案资源管理器中将新的css文件添加到~/ViwUserControl/Style文件夹中。但是我的用户控件没有检索CSS文件。
<link href="~/Content/Styles/demo_page.css" rel="stylesheet" type="text/css" />
<link href="~/Content/Styles/demo_table.css" rel="stylesheet" type="text/css" />
<link href="~/Content/Styles/demo_validation.css" rel="stylesheet" type="text/css" />
<link href="~/Content/Styles/jquery.alerts.css" rel="stylesheet" type="text/css" />
<link href="~/Content/Styles/jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="~/Content/Styles/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" />有什么想法/帮助值得赞赏吗?
当我通过第一个not进行调试时,我看到404没有找到这些文件的错误
发布于 2012-03-09 21:04:25
前面的tilde正在抛出您的代码。
更改:
<link href="~/ ...至:
<link href="/ ...tilde ~是ASP.Net WebForms中常用的服务器端构造,代码如下:
<img runat="server" src="~/Images/foo.png" />.在MVC中,标准是使用@Url.Content(" ... ");,因此:
<link href="@Url.Content("~/Content/Styles/demo_page.css")"
rel="stylesheet" type="text/css" />发布于 2012-03-09 21:03:27
您不能在html中使用~/。唯一的工作与服务器端的功能,以支持该虚拟路径。删除~
https://stackoverflow.com/questions/9640945
复制相似问题