We have old ASP.NET Forms pages and new MVC views and partial views in the same solution. Some pages on the site are MVC and legacy pages are Forms. One of these legacy Forms pages is an .ascx control.
Is there any way for me to insert an MVC partial view (.ascx) into this Forms .ascx control?
I use this technique to embed MVC partials into webforms pages. Not sure if it works in a webforms user control, but it should be possible.
Step 1. Within the MVC part of your application, create the following helper function. This does all the hard work:
then, within your web page (or user control):
add the following to reference the above:
and then when you need to display the partial you can add something like:
where the second parameter is your ‘Model’.
I use this technique extensively in a mixed MVC/Webforms environment and it works like a dream!
Enjoy