Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

_ViewStart and _Layout.cshtml files are automatically created in ASP.NET MVC 5 (annoying)

I am having a Weird and annoying problem. In my ASP.NET MVC 5 project, time to time, I see that _ViewStart file and Shared/_Layout.cshtml files are created automatically even though I did not want. So, I deleted those files but these files are getting created time to time by itself. That cause a great problem because, sometimes, if I dont notice that these files are created, I can accidentally publish the website and then, after publish, I notice that all pages are being wrapped by the auto created _Layout.cshtml file. Is it a smart helping feature of Visual Studio 2013 ? Cant we stop this ?

like image 749
Emran Hussain Avatar asked Nov 10 '22 09:11

Emran Hussain


1 Answers

Emran!

I am not sure that you still need the answer but today I have also met similar problem. By some unknown reason file "Shared/_Layout.cshtml" was automatically added to my Project.

I was realy wondering why could it happen and I found which actions should be performed to make this file be created.


I have added new View to my Project and have used for it standard VS resources:

  1. Right mouse click on Views folder.
  2. Add -> Veiw...
  3. Inside window for adding view I have checked "Use a layout page" and have left field below empty.
  4. Press Add

My VS was thinking a lot and suddenly created new view and also... "Shared/_Layout.cshtml" and "Shared/_ViewStart.cshtml" files!! I do not think that this option might be switched off because it is logically to create layout page when it has been missed.

Hope this info is helpful for you and for anybody else :)

like image 64
Evgenia Avatar answered Nov 15 '22 06:11

Evgenia