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

dotnet on Rails – MonoRail

I was reading a book Pro Spring, which covers DI (Dependency Injection) and MVC on Java. I had the same feeling with peterkrantz, yes, too much configuration works. Rails is way better than that. How can Spring.net succeed?

Then I started looking for asp.net MVC framework, somebody is talking about MonoRail, others prefer Promesh.net, and castle… Finally, I realized that MonoRail is a part of castle open source project. In fact, I needed to install Castle Project assemblies to start playing with MonoRail.

After 2 hours lab, I was so pleased by its similarity to Ruby On Rails. Hope one day MS will adopt it as its official MVC framework to asp.net.

I had some compiling error/warning in my VS2005. “XML document cannot contain multiple root level elements.” in most of my vm(view) files, “Invalid token ‘Text’ at root level of document. ” for “#if($Flash.error)” statement. The web app runs OK with those errors. Later I removed those vm files and re-created one by one by selecting file type as ‘plain text’ instead of ‘HTML’, suddenly, all the errors went away.