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

99封情书 提交于 2019-12-10 16:43:36

问题


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 ?


回答1:


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 :)



来源:https://stackoverflow.com/questions/23317758/viewstart-and-layout-cshtml-files-are-automatically-created-in-asp-net-mvc-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!