What is the correct place for Partial Views in ASP.NET MVC?

后端 未结 2 1787
温柔的废话
温柔的废话 2021-02-05 00:16

Would someone confirm the best place for a partial view in ASP.NET MVC?

My thinkings are if it\'s a global view that\'s going to be used in many places then SHARED.

相关标签:
2条回答
  • 2021-02-05 00:55

    I believe you are correct. Here is an example of something I do, general navigation partial views in my Shared directory. and then a partial views for a specific Controller in the Views/[ControllerName] Directory.

    0 讨论(0)
  • 2021-02-05 01:15

    I think, you're absolutely right!

    Views in the "Views/Shared" folder you can access from all controllers and actions. Views in the "Views/[ControllerName]" folder are for controller specific views only (even if there are possibilities to access them from other controllers).

    0 讨论(0)
提交回复
热议问题