0
votes

So I want to use polymer in order make a stylish mvc webpage. I dont like starting from scratch, because I am still somewhat of a noob when it comes to asp mvc, so I started with Visual studios asp mvc template. The only changes I made was removing references to bootcamp and the nav menu on the _Layout.cshtml and added a core-toolbar (+ some other small html changes). It works well at first but after I make changes in the index file, all polymer styling is lost.

This is my _layout.cshtm:

    <!DOCTYPE html>
    <html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
        <meta name="mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <script src="bower_components/webcomponentsjs/webcomponents.js"></script>
        @*@Styles.Render("~/Content/ArmistanceMaterial.css?"+Guid.NewGuid())*@
        <link rel="import" href="bower_components/core-toolbar/[email protected]()">
        <link rel="import" href="bower_components/font-roboto/[email protected]()">
        <link rel="stylesheet" href="Content/[email protected]()">
        <title>Armistance</title>

    </head>
    <body>
        <core-toolbar>
            <img src="~/Content/Images/Armistance.png" height="50%" style="padding-right:15px;" />
            <span flex>Armistance</span>
        </core-toolbar>
        <section>
            @RenderBody()
        </section>

        <section>

            <hr />
            <footer>
                <p>&copy; @DateTime.Now.Year - My ASP.NET Application</p>
            </footer>
        </section>
        @*@Scripts.Render("~/bundles/webcomponents")*@
    </body>
    </html>

This is my Index.cshtml:

@{
    ViewBag.Title = "Home Page";
}
<div>
    <h1>ASP.NET</h1>
    <p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
    <p><a href="http://asp.net">Learn more &raquo;</a></p>
</div>
    <div >
        <div >
            <h2>Getting started</h2>
            <p>
                ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
                enables a clean separation of concerns and gives you full control over markup
                for enjoyable, agile development.
            </p>
            <p><a  href="http://go.microsoft.com/fwlink/?LinkId=301865">Learn more &raquo;</a></p>
        </div>
        <div >
            <h2>Get more libraries</h2>
            <p>NuGet is a free Viual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.</p>
            <p><a  href="http://go.microsoft.com/fwlink/?LinkId=301866">Learn more &raquo;</a></p>
        </div>
    </div>

And everything seems to be working fine: enter image description here Until I do something like delete or add a div(in this case add). enter image description here

1

1 Answers

0
votes

I think this was caused by my not using a path relative to the root, but to the current view dir. Which is weird in my opinion because I didn't think refreshing the page would change the active directory.

Fix: add "~/" to the beginning of paths

FYI: I figured this out shortly after posting this, just wanted to clarify that this stupid mistake did not take me a week to figure out.