简体   繁体   中英

Css is not working properly in asp.net mvc3 Razor Views

I have a application on asp.net mvc3 and working in a razor view. On my layout page I attach a css file and put some css in that file, but when I access /Account/LogOn view the css is not working.
It only works if I attach the css on Logon view. Anyone know why my css attached on the layout page is not working on /Account/LogOn ?

I also tried by including following code:

@{
Layout = "~/Views/Shared/_Layout.cshtml";
ViewBag.Title = "xyz.com – Login";
 }

It is still not working. Thanks in advance

像这样使用url helper引用你的css

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

In your _layout.cshtml , ensure that you use a path referencing the root (~) of your application. Use @Url.Content() to escape the path:

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

Create the stylesheet under the folder Contents by the name say abc.css

Now include the stylesheet in the LayoutPage so that it is included automatically in all the pages derived from the content page.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM