Share static html in MVC views

PartialView can be used to share page content, but our shared content are purely static and would like to share it among multiple web apps, doesn’t have to be MVC apps.

We have tried SSI (Server side include) on IIS,  but it turns out it doesn’t work in Razor view. Spuriously, many people said SSI is dead, and by default IIS7 doesn’t turn SSI on, here is the doc how to install and configure SSI on IIS7. install it, configure it (if your included file is not named as shtm)

For now the best solution I found is putting this code in Razor view.

@MvcHtmlString.Create(File.ReadAllText(Server.MapPath(“/_shared/footer.htm”)))

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s