I'm working on a ASP.NET WebForms website that is being converted to ASP.NET MVC over time. While I'm very well aware that MVC "pages" can coexist in the same Web Application with ASP.NET WebForm ASPX pages, I don't know how I can consolidate HTML that needs to exist on both pages.
For Example A header and a footer are such HTML fragments in my context. On web pages built with either MVC and ASPX, I want to render the exact same HTML markup for the header and footer. At the moment, the code base I'm working on has two headers and two footers:
- header.ascx
- footer.ascx
- _header.cshtml
- _footer.cshtml
I'd like to avoid having two sets of HTML markup. This is duplicate code, and the header has a lot of markup in it.
What can be done for an MVC 3/4/5 web application? How can html markup of the header/footer be consolidated to only 1 source, while delivering the markup on the page loads?
NOTE: I haven't had success with rendering an MVC Partial View inside an ASPX Webform.