Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show partial view from different folder

Is that possible to access partial view which is placed in external folder?


enter image description here

I want to show a _LoginPartial on a page /Home/Index, but _LoginPartial should be in /Auth.

When I am trying to specify /Home/Index to take this partial from /Auth, I've getting an error.

@Html.Partial("/Auth/Login")

ErrorLog says that

Message=The partial view 'Views/Auth/Login' was not found or no view engine supports the searched locations. The following locations were searched:

~/Views/Home/Auth/Login.aspx

~/Views/Home/Auth/Login.ascx

~/Views/Shared/Auth/Login.aspx

~/Views/Shared/Auth/Login.ascx

~/Views/Home/Auth/Login.cshtml

~/Views/Home/Auth/Login.vbhtml

~/Views/Shared/Auth/Login.cshtml

~/Views/Shared/Auth/Login.vbhtml

So I know that it is trying to find my partial only inside /Home directory.

like image 241
Arsinclair Avatar asked Oct 21 '25 09:10

Arsinclair


1 Answers

Use the full path to your partial view.

@Html.Partial("~/Views/Auth/Login.cshtml")
like image 175
Shyju Avatar answered Oct 24 '25 08:10

Shyju