Home > database >  InvalidOperationException: The partial view was not found. MVC3.1
InvalidOperationException: The partial view was not found. MVC3.1

Time:12-21

Admin/Dashboard.cshtml:

<partial name="Partials/_Dash.cshtml" />

I'm trying to create a partial view _Dash.cshtml menu for the dashboard panel. However, I'm getting the following error:

Error:

An unhandled exception occurred while processing the request.
InvalidOperationException: The partial view 'Partials/_Dash.cshtml' was not found. The following locations were searched:
/Views/Admin/Partials/_Dash.cshtml

Microsoft.AspNetCore.Mvc.TagHelpers.PartialTagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output)

I already have Partial View _Menu which is called in _Layout:

<partial name="Partials/_Menu.cshtml" />

and it's working fine.

What could be the problem?

CodePudding user response:

I always use the full path for a view that is not in default folder

<partial name="~/Views/..... /Partials/_Dash.cshtml" />

or you can move the partial view in a Shared folder, in this case

<partial name="_Dash" />
  • Related