简体   繁体   中英

Put all the view into one view sub folder in MVC

I'm a very beginner(Learner) in MVC. Is this question is stupid, sorry for that. I'm having three controllers

  • Home
  • Main_Menu
  • Booking

Added view for this controller and its having three sub folder views

  • View/Home/Home.cshtml
  • View/Main_Menu/Main_Menu.cshtml
  • View/Booking/Booking.cshtml

Is it possible to put all view into one sub folder like this

  • View/Home/Home.cshtml
  • View/Home/Main_Menu.cshtml
  • View/Home/Booking.cshtml

Is this stupid? Is this bad approach?

ASP.NET MVC already have such all in one folder - Views/Shared

If you put your view there and call Controller , that don't have View in it's own folder you get the View from Shared .

Also, you can try to change View location by creating Custom View Engine but it's not so easy. You can find how to do it here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM