Everyone, I'm using MVC 3 (Razor). I have the following problem:
I have some common contents segregated into a partial view. But rather than to put it in the default location (views/shared
or views/controller-name
), I need to put it in a different location (views/shared/new-folder
or view/controller-name/new-folder
).
I tried this : @Html.Partial("views/shared/new-folder/partial-view-name")
or even @Html.Partial("views/shared/new-folder/partial-view-name.cshtml")
,but it seems that MVC3 only consider the parameter as a view name, and it totally ignored any path information.
Maybe I did something wrong ,can anybody help me with this ?:) Thank you very much!
You need to reference using an application virtual path (notice the ~\
at the beginning of the path):
@Html.Partial("~\\views\\shared\\new-folder\\partial-view-name.cshtml")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With