Master Page & Registering scripts, css in MVC 4 Razor view engine

Hi folks,

         For the past couple of months my team were discussing about using MVC 4 RAZOR view engine.
We had couple of go thorough with it. But, Finally a doubt arose on my mind just before the day to kick off.

        So I woke up mind and started to have a look and I found about adding master page,and two more thinks with it. (CSS & Script registering).

MasterPage? Where is it???

       With the MVC 4 Razor view template you can find several cshtml pages under Views/Shared. I bet you not all off them are master pages.

       By default you can find _Layout.cshtml (considerably the default master page).(See Image)


How it is refereed to a view(page)? 

      If you choose to keep the default master page while you creating a view, then you can find the reference under Views/_ViewStart.cshtml

   Else, It will be mentioned in the view(page) it self...


  You can add custom master page as a default master page by changing that in _ViewStart.cshtml


     



So, Where we register Script & Css???

    Here we go,open up the _Layout.cshtml to get a clear view on it..


you could see 

       @Styles.Render("~/Content/css")
        @Scripts.Render("~/bundles/modernizr")

 I spend a ample time on searching bundles folder in my application and finally found that is not a "directory" (?!!!)

What really it is??

Go to App_Start/BundleConfig.cs



There you find how it is refereed.


I made the post with screenshots rather with text, hope you found this helpful.


    

Comments

Popular posts from this blog

How to Checkout External Repositories in Azure DevOps Build Pipeline: A Step-by-Step Guide

Cache Purging in Azure Front Door with Azure PowerShell and CLI