How do you include .html or .asp file using razor?
asp.net-mvc-3, razor
Solution
Razor does not support server-side includes. The easiest solution would be copying the menu markup into your _Layout.cshtml page.
If you only needed to include .html files you could probably write a custom function that read the file from disk and wrote the output.
However since you also want to include .asp files (that could contain arbitrary server-side code) the above approach won't work. You would have to have a way to execute the .asp file, capture the generated output, and write it out to the response in your cshtml file.
In this case I would go with the copy+paste approach
Problem
Is it possible to use server side include in Razor view engine to include .html or .asp file? We have an .html file and .asp files that contain website menus that are used for all of our websitse. Currently we use server side include for all of our sites so that we only need to change the mensu in one place. I have the following code in the body of my _Layout.cshtml ``` <body> <!--#include virtual="/serverside/menus/MainMenu.asp" --> <!--#include virtual="/serverside/menus/library_menu.asp" --> <!--#include virtual="/portfolios/serverside/menus/portfolio_buttons_head.html" --> @RenderBody() </body> ``` Instead of including the content of the file, if I do a view source, I see the literal text. ``` " <!--#include virtual="/serverside/menus/MainMenu.asp" --> <!--#include virtual="/serverside/menus/library_menu.asp" --> <!--#include virtual="/portfolios/serverside/menus/portfolio_buttons_head.html" -->" ```