0

I've been googling for a while trying to see the use of the file _ViewStart.cshtml but the only one I see is setting the layout to the views statically or dynamically

enter image description here

Can I use the file _ViewStart.cshtml to do something else?

vcRobe
  • 1,671
  • 3
  • 17
  • 35

2 Answers2

0

It is used set the default layout for the website. This can be overridden in the view.

Additionally you could write logic to change the layout for some reason e.g. different layout for different devices.

You could also save data to the tempdata.

Scrobi
  • 1,215
  • 10
  • 13
0

Some understanding around the purpose of the ViewStart page:

Where and how is the _ViewStart.cshtml layout file linked?

https://www.exceptionnotfound.net/asp-net-mvc-demystified-layout-viewstart-renderbody-and-rendersection/

Brian Mains
  • 50,520
  • 35
  • 148
  • 257
  • Reading the links I found the definite answer to my question here http://weblogs.asp.net/gunnarpeipman/archive/2010/10/10/asp-net-mvc-3-beta-view-start-files-for-razor-view-engine.aspx. Thank you for your help – vcRobe Jun 09 '17 at 21:19