Create controller for partial view in ASP.NET MVC

后端 未结 6 471
情话喂你
情话喂你 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:12

    It does not need its own controller. You can use

    @Html.Partial("../ControllerName/_Testimonials.cshtml")
    

    This allows you to render the partial from any page. Just make sure the relative path is correct.

提交回复
热议问题