开发者

.NET MVC URL IgnoreRoute?

In my application, I am having problems getting a stylesheet because it is using the URL, and trying to find a corresponding controller. For Example,

I have the following in one of my views:

<link href="~/Content/css/styles.css" type="text/css"/>

Which when the page loads, throws a 500 error, and tells me that...

www.mysite.com/design/Content/css/styles.css could not be found

It is using design as the area, because that is the name of the package it is in.

What do I need开发者_运维百科 to do in order to hit my static css file at the above address, without it trying to find a controller named "Content"?


Shouldn't the html be rendered using:

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

Or:

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

(If you are using Razor).

I dont think this is an issue with your MVC routes, but more that you are not resolving the url correctly.


It sounds like you want a domain-relative path rather than an application-relative path.

Remove the ~.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜