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. I am current rendering the partial as so
@Html.Partial("_Testimonials")
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. I am current rendering the partial as so
|
|||
|
Why not use Then you could put the following into any controller (even creating a new controller for it):
Then you could create a new partial view and have your For Razor, the code block in the view would look like this:
For the WebFormsViewEngine, it would look like this:
|
|||||||||||||||||
|
It does not need its own controller. You can use
This allows you to render the partial from any page. Just make sure the relative path is correct. |
|||||||||||||
|
If it were me, I would simply create a new Controller with a Single Action and then use RenderAction in place of Partial:
|
|||||
|
The most important thing is, the action created must return partial view, see below.
|
|||
|