Aleksa Ristic
Aleksa Ristic

Reputation: 2499

Partial from other folder than shared

I want to render partial view in my asp.net core application.

Earlier i was using @Html.Partial() function but VS suggested me to change it to normal <partial> and from that moment i am using it like that since i rendered only few partial views so i stored them in shared folder but now i started using it more often and problem i am having is i want to sort them in folders.

I looked at answers but all are using @Html.Partial() like this one but no answer with normal <patial> tag.

I tired doing it like this:

<partial name='~/Folder/View' model='new Model()' but it is not working just as any combination with/without ~ / and other signs.

Upvotes: 0

Views: 3025

Answers (1)

Xueli Chen
Xueli Chen

Reputation: 12705

The name attribute is required. It indicates the name or the path of the partial view to be rendered. When a partial view name is provided, the view discovery process is initiated. That process is bypassed when an explicit path is provided. For all acceptable name values, see Partial view discovery.

Reference :

https://learn.microsoft.com/en-us/aspnet/core/mvc/views/partial?view=aspnetcore-2.2

Upvotes: 1

Related Questions