Home How do I call an external stylesheet from a .cshtml page?
Reply: 0

How do I call an external stylesheet from a .cshtml page?

user2071 Published in June 20, 2018, 1:28 am

I have a view page (View.cshtml) and a stylesheet (Style.css).

The stylesheet is located in a folder called "Stylesheet", and the view page is located in Views/Home/View.cshtml. I am trying to link the stylesheet to the view page by this code:

<link rel="stylesheet" type="text/css" href="~/Stylesheet/Style.css">

When I run the project, it showed the contents of the view page but the styling was not implemented. May I know what I am doing wrong?



<!DOCTYPE html>

    <meta charset="utf-8" />
    <link rel="stylesheet" type="text/css" href="~/Stylesheet/Style.css" /> ‌
    <title>Test Page</title>


    <div id="topHeader">
        <br />

        <div id="credentialsBox">

            <div id="texts">
                <div id="word1">Username:</div>
                <div id="word2">Password:</div>


@font-face {
    font-family: 'proximanova';
    src: url('../fonts/proximanova-light-webfont (2)_0.ttf') format('truetype');

/*CSS Styling Properties*/
body {
    font-family: proximanova;
    margin: 0;
    background-color: #007381;

    margin-top: 15%;
    height: 450px;
    background-color: #d6d6d6;

#credentialsBox {
    border-radius: 3%;
    width: 20%;
    margin: auto;
    margin-top: -5%;
    background-color: #ffffff;

#texts {
    padding: 14%;
    text-align: center;


<!DOCTYPE html>

        @RenderSection("css", false)



Sorry if the CSS styling is a bit messy, I am trying my best to learn here :D

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.305178 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO