Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 113793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:45:30+00:00 2026-05-11T02:45:30+00:00

There is a directory in the standard ASP.NET template Content where most people seem

  • 0

There is a directory in the standard ASP.NET template ‘Content‘ where most people seem to be putting in images and css files etc.

For instance stackoverflow’s logo:

alt text
(source: stackoverflow.com)

actually is refered to with a server path containing ‘content’ in the URL (just do View Source for any SO page and you’ll see this). So they obviously are storing images in ‘content/images/...‘.

src='/Content/Img/stackoverflow-logo-250.png'  

Edit: Sometime in the last 10 years they changed the path – but this is what it used to be.

I dont particularly like this. My HTML ends up with /content all over it, and its slightly harder to migrate existing pages that just have /image. Fortunately my stylesheet doesnt end up with content all over it, as long as I save it in content\site.css.

An alternative is to put an images directory in the root, but then you get images at the same level as Controllers and Views which is pretty horrible.

I’d wondered about trying to add a redirection rule like this :

routes.RedirectRoute(    'images rule',    'Images/{*}',    'Content/Images/{1}');    // this is NOT valid code - I made it up 

But that code doesnt work because I just made it up. I could use a third party redirection/rewriting plug-in but I want to keep everything ‘pure’ within the MVC model.

What has anyone else found in this area? Or is everyone just happy with an extra ('/content'.length) bytes in their source for every image they serve.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T02:45:31+00:00Added an answer on May 11, 2026 at 2:45 am

    To be honest, I don’t think its really something to worry about… ‘/Content’ is going to make a pretty minimal contribution to your page size. If you still want to do it, here are some options:

    Option 1, if you are running on your own server, is to check out the IIS URL Rewrite module: http://learn.iis.net/page.aspx/460/using-url-rewrite-module/

    Option 2 is to use either RedirectResult, or ContentResult, to achieve the same effect in the MVC framework

    First, map a ‘catchall’ route under ‘Images/’ to a controller action, like so

    routes.MapRoute('ImageContent',                  'Images/{*relativePath}',                   new { controller = 'Content', action = 'Image' }) 

    Make sure it is above your standard ‘{controller}/{action}/{id}’ route. Then, in ContentController (or wherever you decide to put it):

    public ActionResult Image() {     string imagePath = RouteData.Values['relativePath']     // imagePath now contains the relative path to the image!     // i.e. http://mysite.com/Images/Foo/Bar/Baz.png => imagePath = 'Foo/Bar/Baz.png'     // Either Redirect, or load the file from Content/Images/{imagePath} and transmit it } 

    I did a quick test, and it seemed to work. Let me know in the comments if you have any problems!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to rename the files in a directory.There are 52 folders in the
There's a directory with a few text files. How do I count the frequency
I have an ASP.NET application that authenticates users using Ldap against active directory. This
I'm using ASP.NET 4, EF 4 and FILESTREAM in SQL 2008 to add/read files
Is there a simple command to add a directory and all files underneath it
I have a couple of standard ASP.NET web methods that I'm calling from javascript
Have a WCF service in a Services directory in my asp.net web app. In
I have a standard ASP.NET MVC (version 2 preview 2) solution with the actual
I'm currently creating some custom helper classes, similar to ASP.NET MVC's standard HtmlHelper .
I've read through a number of these questions about Asp.net MVC and directory structures,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.