Home > front end >  How can I link an external css stylesheet to a View in the ASP.NET MVC framework?
How can I link an external css stylesheet to a View in the ASP.NET MVC framework?

Time:04-24

I have created a Site.css stylesheet under Content folder in my MVC architecture however I don't see any changes in my VIEW after adding styles to it. How do I link them together? Solutions Explorer in Visual Studio VIEW example:

@model SchoolProject.Models.Teacher
@{
    ViewBag.Title = "Delete";
}

<h2>Warning: Deleting is permanent</h2>

<div>
    <div>@Model.FirstName @Model.LastName</div>
</div>

<form method="POST" action="/Teacher/DeleteTeacher/@Model.Id">

    <div>
        <input type="submit" value="Delete" />
    </div>
</form>

CodePudding user response:

If you using Layout page in your View:

Open Views->Shared->Layout.cshtml and to the header drag & drop the Site.css file.

if You not using Layout page in your View, you have to drag & drop the Site.css file in your View.

CodePudding user response:

You can check or link your css inside 'BundleConfig.cs' file. You can navigate it App_Start>BundleConfig.cs here you can find code to link your css file

bundles.Add(new StyleBundle("~/Content/css").Include(
                  "~/Content/bootstrap.css",
                  "~/Content/site.css"));
  • Related