ASP.NET MVC – Serving Static Content

Overlapping colored triangles

In your MVC sites, you often need to serve up miscellaneous static content, such as http://example.com/About, http://example.com/Contact, etc.
Instead of creating controllers for each of these, you can organize them into a single controller like so:

	new { controller = "StaticContent" },
	new { action = "About|Contact" } // Add more here

Create your StaticContentController with action methods About() and Contact(), and you're good to go!
The important part is the constraint new { action = "About|Contact" } (which is a regular expression) that will prevent any other URLs from inadvertently using this route.

About the Author:



VisionFriendly.com has been building successful websites for over 20 years and covers all areas of website design, development and marketing with creative custom web designs and a robust in-house team of programmers to get your web marketing to work exactly the way you need it to.

Share On:

Share on facebook
Share on twitter
Share on linkedin


Leave a Comment

Your email address will not be published. Required fields are marked *

Copyright © 2021, All Rights Reserved
Tri Colored Triangles
Scroll to Top

Take your business to the

Next Level!

Visionfriendly.com has the right team to make your business stand out from other professional websites.

Ready For Takeoff?

A Completely Customized
Digital Marketing Experience

We'll be in touch within one business day to discuss your goals and create a personalized plan that fits both you and your business.

Let’s start a Conversation