Create controller for partial view in ASP.NET MVC

后端 未结 6 478
情话喂你
情话喂你 2020-12-07 14:34

How can I create an individual controller and model for a partial view? I want to be able to place this partial view any where on the site so it needs it\'s own controller.

6条回答
  •  被撕碎了的回忆
    2020-12-07 15:06

    You don't need a controller and when using .Net 5 (MVC 6) you can render the partial view async

    @await Html.PartialAsync("_LoginPartial")
    

    or

    @{await Html.RenderPartialAsync("PartialName");}
    

    or if you are using .net core 2.1 > you can just use:

    
    

提交回复
热议问题