asp.net mvc 区域内样式表中的相对路径 [英] relative path in stylesheets within asp.net mvc areas

查看:33
本文介绍了asp.net mvc 区域内样式表中的相对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个当前结构的项目

I have a project with the current structure

My Project
  /Content
  /Controller
  /View
  /Model
  /Areas
     /Area1
        /View
        /Controller
        /Model
     /Area2
        /View
        /Controller
        /Model

所有区域视图都使用根共享 _Layout 视图,该视图引用根内容目录下的 css 文件.content 文件夹下的 css 文件正在引用图像或其他具有相同目录的内容,如下所示:

All of the area views are using a root shared _Layout view which is referencing a css file under the root content directory. The css file under the content folder is referencing images or other content with the same directory like below:

.box-shadow
{
    -webkit-box-shadow: 0px 5px 80px #505050;
    -moz-box-shadow: 0px 5px 80px #505050;
    box-shadow: 0px 5px 80px #505050;
    behavior: url('../Content/PIE.htc');
}

当我访问http://MyProject/controller/action"时,所有这些都工作正常,但是当我进入一个区域http://root/area/controller/action"时,我的 css 文件无法找到路径../Content/PIE.htc".

All of this works fine when i access 'http://MyProject/controller/action', but when i go into an area 'http://root/area/controller/action' my css file is not able to find the path '../Content/PIE.htc'.

我不知道如何解决这个问题,所以我想知道是否有人知道解决这个问题的方法.

I don't know how to go about fixing this so i was wondering if anyone knew of a way to fix this.

谢谢!

推荐答案

如果所有区域的所有视图都使用根共享_Layout (~/Views/Shared/_Layout.cshtml),请确保_Layout.cshtml调用了css文件如以下代码:

If all the views in all the areas are using root shared _Layout (~/Views/Shared/_Layout.cshtml), make sure that _Layout.cshtml calls css file like the following code:

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

我使用 MVC 3 对其进行了测试,并且可以正常工作.

I tested it with MVC 3 and it works.

这篇关于asp.net mvc 区域内样式表中的相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆