Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MVC ViewUserControl未检索css样式表_Css_Asp.net Mvc 2 - Fatal编程技术网

MVC ViewUserControl未检索css样式表

MVC ViewUserControl未检索css样式表,css,asp.net-mvc-2,Css,Asp.net Mvc 2,我已经创建了新的MVC2 ViwUserControl 我已经在我的解决方案资源管理器的~/Content/Styles文件夹中添加了新的css文件。 但是我的用户控件没有检索CSS文件 <link href="~/Content/Styles/demo_page.css" rel="stylesheet" type="text/css" /> <link href="~/Content/Styles/demo_table.css" rel="styleshe

我已经创建了新的MVC2 ViwUserControl 我已经在我的解决方案资源管理器的~/Content/Styles文件夹中添加了新的css文件。 但是我的用户控件没有检索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" />

您有什么想法/帮助吗


当我通过firbug进行调试时,我看到这些文件出现了404未找到错误

您不能在html中使用
~/
。仅与支持该虚拟路径的服务器端功能配合使用。删除
~

前面的
tilde
正在删除您的代码

更改:

<link href="~/ ...

在MVC中,标准是使用
@Url.Content(“…”)so:

<link href="@Url.Content("~/Content/Styles/demo_page.css")"
      rel="stylesheet" type="text/css" />

<img runat="server" src="~/Images/foo.png" />.
<link href="@Url.Content("~/Content/Styles/demo_page.css")"
      rel="stylesheet" type="text/css" />