partial view was not found or no view engine supports the searched locations

后端 未结 6 2038
野的像风
野的像风 2020-12-17 07:22

I have following controller code:

public MyController:Controller
{
    public ActionResult Index()
    {
        return View();
    }

    [ChildActionOnly]
         


        
6条回答
  •  猫巷女王i
    2020-12-17 08:22

    Hope, this code helps you (In ".cshtml" file)

    @using Microsoft.AspNetCore.Mvc.ViewEngines
    @inject ICompositeViewEngine Engine
    
    ....
    string path = "../Themes/User/_head";
    
    @if (Engine.FindView(ViewContext, path, isMainPage: false).Success)
    {
        
    }
    else
    {
        
    }
    

    Thanks

提交回复
热议问题