Our Black Friday Sale has been extended!  View Sale

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 is a Chicago digital marketing agency with over 25 years of experience helping clients nationwide. We have an in-house team of marketers and creatives ready to improve your business’s marketing operations.

Share On:


Leave a Comment

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

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

We’re Doing Something Awesome

VisionFriendly.com is now Blackbird Digital.

We are the same great people, with a new name, new website, and new ideas.

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.

  • This field is for validation purposes and should be left unchanged.

Let’s start a Conversation