开发者

Styles, scripts and images in Area folder

开发者 https://www.devze.com 2023-03-19 18:02 出处:网络
I\'ve setup an Admin area within MVC 3 application and while everything is working when I reference files from the root Scripts, Styles and Images folder, it doesn\'t work when I created those folders

I've setup an Admin area within MVC 3 application and while everything is working when I reference files from the root Scripts, Styles and Images folder, it doesn't work when I created those folders under /Areas/admin/ and referenced them like this:

@Script.Include("~/admin/Scripts/superfish-1.4.8/js/superfish.js")

Please note th开发者_如何学运维at this Script.Include helper is something that I have that essentially spits out this:

<script type="text/javascript" src="/admin/Scripts/superfish-1.4.8/js/superfish.js"></script>

So the helper is working and everything is fine when I reference like this

@Script.Include("~/Scripts/superfish-1.4.8/js/superfish.js")

but not when I introduce the area name in there. It results in a 404 Error.


That's because the actual path to your script is the following:

@Script.Include("~/areas/admin/Scripts/superfish-1.4.8/js/superfish.js")

which should render:

<script type="text/javascript" src="/areas/admin/Scripts/superfish-1.4.8/js/superfish.js"></script>

Notice the Areas prefix that I added.

0

精彩评论

暂无评论...
验证码 换一张
取 消