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 8463189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:23:43+00:00 2026-06-10T14:23:43+00:00

Is there a way to give an ASP.NET MVC 4 project a public folder,

  • 0

Is there a way to give an ASP.NET MVC 4 project a “public” folder, which would act like the application root, like in Ruby on Rails?

ASP.NET MVC usually comes with a “Content” folder where you can put statically served files like style sheets, scripts, and images. But the URLs for these files have to include the Content folder, for example <img src="/Content/logo.png">.Is it possible to make the Content folder the root of the application so you can use this instead: <img src="/logo.png">?

  • 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. Editorial Team
    Editorial Team
    2026-06-10T14:23:44+00:00Added an answer on June 10, 2026 at 2:23 pm

    I’m not sure why I didn’t think of this before, but I was able to accomplish this with IIS URL Rewrite. The following rules assume a folder named “Public” where your static files reside. Of course, you can name the folder whatever you want.

    <!-- Any direct references to files in the Public folder should be
         301 redirected to maintain canonical URLs. This is optional. -->
    <rule name="Public folder canonical path" stopProcessing="true">
      <match url="^public/(.*)" />
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
      <action type="Redirect" url="{R:1}" appendQueryString="true" />
    </rule>
    
    <!-- Any URL that points to an existing file after prepending "Public" to it
         will serve that file. For example, if a file exists at /Public/style.css
         then the URL /style.css will serve that file. Likewise, if a file exists
         at /Public/images/logo.png, then the URL /images/logo.png will serve
         that file. Files in the Public folder will take precedence over files in
         the application root, so if a file /Public/script.js exists and a file
         /script.js exists, only the /Public/script.js file will be served. This
         also takes precedence over MVC routes. -->
    <rule name="Public folder" stopProcessing="true">
      <match url=".+" />
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{URL}" pattern="^/Public/" negate="true" />
        <add input="{DOCUMENT_ROOT}/Public{URL}" matchType="IsFile" />
      </conditions>
      <action type="Rewrite" url="Public/{R:0}" appendQueryString="true" />
    </rule>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In ASP.NET MVC is there a way to enumerate the controllers through code and
My ASP.NET MVC site allows users to register and give themselves user names, which
In ASP.NET MVC I have a controller that looks somehow like this: public class
I am currently working on an ASP.NET MVC2 application and would just like to
I am developing an asp.net mvc 2 web application. My clients will most likely
I'm building an asp.net MVC application where users can attach a picture to their
We have an ASP.NET MVC web app which allows users to publish messages onto
I have an asp.net mvc application with three layers: - data layer with entities
I use the include Method in my asp.net mvc 2 project with EF 4.0
I have an ASP.NET MVC Web Application that interacts with a SQL Server 2008

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.