问题
Is it possible to render partial view without ViewContext or ControllerContext?
- I'm trying to get PartialView Html as string from outside of Controller Action.
- OR
- Is it possible to call Controller Action from another method? (this will allow me to execute controller action and get partial view html this way).
回答1:
You can try the Razor Generator Visual Studio Extension. Basically you run the custom tool on your view and it will generate a class that you can pass a model into and it will generate a string.
来源:https://stackoverflow.com/questions/15896703/mvc-render-partial-view-without-httpcontext-or-controller-context