Asp.net MVC - Render a partial View From an Area

前端 未结 3 2036
走了就别回头了
走了就别回头了 2021-01-12 21:34

I\'ve created an area that will handle our some generic things across all our development products, just as log ins, HTML helpers, etc. Inside the area, I have a partial vi

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-12 22:09

    An important thing to remember is that when using RenderPartial you use it in the context of the current action.

    As your action isn't in an area it will only look in the View/ folder for the controller the action belongs to then the shared folder.

    Any views you wish to share between areas and controllers and have available at the route should be the root View/Shared folder. Really if the view is callable as a partial like that there is probably little reason for it to belong to an area.

    You can call into area when you want to render actions rather than partials - which then changes the context of the current action to the action you call into thereby allowing you to then return views within that area.

提交回复
热议问题