I have created a new login layout for my login page and cannot get the css file to link.
I have tried not using a layout page at all, using @{Layout = null} and rendering an entire HTML page (header tags...etc) and linking the CSS in the header tags and nothing. I have also moved the login.css link above the bootstrap link and it still isn't rendering any CSS. Now I have a LoginLayout with the CSS and bootstrap files linked in the header tags. Still nothing.
My bootstrap is rendering, but not my CSS. Can anyone help with linking the login.css file to _LoginLayout.cshtml?
_LoginLayout.cshtml:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title | Knowledgebase</title>
<link href="@Url.Content("~/Content/bootstrap.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/login.css")" rel="stylesheet" type="text/css" />
</head>
<body>
<div>
@RenderBody()
</div>
</body>
</html>
Login.cshtml View:
@model ITKnowledgebase.Models.LoginModel
@{
ViewBag.Title = "Login";
Layout = "~/Views/Shared/_LoginLayout.cshtml";
}
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="container">
<div class="form-horizontal">
<br>
<img src="~/Content/Images/logo.png">
<br> <br>
<h2>Knowledgebase Sign In</h2>
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="pnlMain">
<label class="sr-only">ID</label>
@Html.EditorFor(model => model.Id, new { htmlAttributes = new { placeholder = "ID", @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Id, "", new { @class = "text-danger" })
<label class="sr-only">Username</label>
@Html.EditorFor(model => model.Username, new { htmlAttributes = new { placeholder = "Username", @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Username, "", new { @class = "text-danger" })
<label class="sr-only">Password</label>
@Html.EditorFor(model => model.Password, new { htmlAttributes = new { placeholder = "Password", @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Password, "", new { @class = "text-danger" })
</div>
<input type="submit" value="Sign In" class="btn btn-primary" id="btnSubmit" />
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<hr />
<footer>
<p>© | All rights reserved.</p>
</footer>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
AccountController:
namespace ITKnowledgebase.Controllers
{
public class AccountController : Controller
{
// GET: Account
public ActionResult Login()
{
var login = new LoginModel();
return View(login);
}
[HttpPost]
public ActionResult Login(LoginModel login)
{
if (ModelState.IsValid)
{
return RedirectToAction("Index", "Home", login);
}
return View(login);
}
}
}
I am expecting the background to turn blue as my login.css file includes:
body {
font-size: 27px;
background-color: lightblue;
}