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" -->"
Razor is a markup syntax for embedding . NET based code into webpages. The Razor syntax consists of Razor markup, C#, and HTML. Files containing Razor generally have a . cshtml file extension.
An Active Server Pages (ASP) file is a text file with the extension . asp that contains any combination of the following: text, HTML tags, and server-side scripts in an COM-compliant scripting language such as Microsoft VBScript?.
Step 1: Right click on the "Controllers" folder and add "LoadHtml" controller. Copy and paste the following code. Step 2: Right click on the "Index" action method in the "LoadHtmlController" and add "Index" view.
html is strictly processed by the client, typically a browser. cshtml is the file extension that refers to the razor view engine. In addition to straight html, these files also contain C# code that is compiled on the server prior to the pages being server up to the browser..
@Html.Raw(File.ReadAllText(Server.MapPath("~/content/somefile.css")))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With