Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you include .html or .asp file using razor?

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" -->" 
like image 613
atbebtg Avatar asked Mar 15 '11 16:03

atbebtg


People also ask

What is HTML Razor?

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.

What is .asp file in HTML?

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?.

How can add HTML file in MVC project?

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.

What is difference between .cshtml and .HTML file?

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..


1 Answers

@Html.Raw(File.ReadAllText(Server.MapPath("~/content/somefile.css"))) 
like image 151
Mads Klinkby Avatar answered Oct 04 '22 08:10

Mads Klinkby