Render partial from different folder (not shared)

2019-01-12 17:53发布

How can I have a view render a partial (user control) from a different folder? With preview 3 I used to call RenderUserControl with the complete path, but whith upgrading to preview 5 this is not possible anymore. Instead we got the RenderPartial method, but it's not offering me the functionality I'm looking for.

8条回答
爷的心禁止访问
2楼-- · 2019-01-12 18:16

you should try this

~/Views/Shared/parts/UMFview.ascx

place the ~/Views/ before your code

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-01-12 18:18

In my case I was using MvcMailer (https://github.com/smsohan/MvcMailer) and wanted to access a partial view from another folder, that wasn't in "Shared." The above solutions didn't work, but using a relative path did.

@Html.Partial("../MyViewFolder/Partials/_PartialView", Model.MyObject)
查看更多
登录 后发表回答