I have a folder structure as follows:
In my Startup.cs
I have:
app.UseEndpoints(endpoints =>
{
endpoints.MapAreaControllerRoute(
"Admin",
"Admin",
"admin/{controller=Dashboard}/{action=Index}/{id?}");
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
In my ```FormsController` I have:
[IsRole(RoleEnum.Admin)]
[Area("Admin")]
[Route("admin/forms")]
public class FormController
{
[HttpGet("skips")]
public async Task<IActionResult> EditSkip()
{
return PartialView("Skips/_Edit.cshtml");
}
}
For some reason, the view can't be found as I get this error message:
The view 'Skips/_Edit.cshtml' was not found. The following locations were searched: /Skips/_Edit.cshtml
I've tried using:
return View("~/Areas/Admin/Forms/Skips/_Edit.cshtml");
But still no luck, I'm not sure what I'm doing wrong I've followed everything on Google and other stackoverflow answers but I've got to be missing something
CodePudding user response:
The path should start right after the Views folder.
Which in your case starts from Forms -> Skips -> _Edit.cshtml
return PartialView("Forms/Skips/_Edit.cshtml");
CodePudding user response:
you missed a view folder. try this url
return View("~/Areas/Admin/Views/Forms/Skips/_Edit.cshtml");