Dhanush K
What is ViewStart?

What is ViewStart in MVC(ModelViewController)?

By Dhanush K in ASP.NET on Jan 12 2022
  • Ashok Kumawat
    Jan, 2022 17

    You can follow this link to know about ViewStart in MVC.

    https://www.c-sharpcorner.com/UploadFile/618722/viewstart-page-in-Asp-Net-mvc-3/

    • 2
  • Sardar Mudassar Ali Khan
    Feb, 2023 28

    Code that is run at the start of each Razor Page’s execution is found in the _ViewStart.cshtml file. All Razor Pages contained in the same folder as the ViewStart file or any of its subfolders are impacted by the ViewStart file. Hierarchical files exist in ViewStart. The file system will execute files stored in subfolders before those situated higher up.

    Setting the layout page for each Razor Page is the most frequent application of the ViewStart file. Server-side code must be contained in a Razor code block because the ViewStart file is a Razor Page:

    1. @{
    2. Layout = "_Layout";
    3. }

    • 1
  • Vishal Yelve
    Jul, 2022 8

    In simple term I can say that if suppose I am adding 100 views in my project and want to add this common layout in each view then I have to set this layout property in each view.In future if I will change this common layout name or location I have to make changes in each view too, which is little bit hectic.So Razor View Engine introduced a new layout named _ViewStart which is applied on all view automatically. Razor View Engine firstly executes the _ViewStart and then start rendering the other view and merges them.In this situation we need not to set the layout property in each view.

    • 0
  • Kelly Peters
    Mar, 2022 6

    _ViewStart.cshtml file is used to define the common layout page for all the views you add to your project. If you add a view, you see below dialog box to provide the View name, View Engine and Layout or master page.

    AFFORDABLE SEO SERVICES

    • 0
  • Faina Smirnoff
    Feb, 2022 21

    ACCORDING TO MY RESEARCH THE VIEWSTART.CSHTML PAGE IS A SPECIAL VIEW PAGE CONTAINING THE STATEMENT DECLARATION TO INCLUDE THE LAYOUT PAGE. SEO company in Cincinnati

    • 0
  • Arvind Yadav
    Jan, 2022 28

    a special view page containing the statement declaration to include the Layout page

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS