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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:55:18+00:00 2026-06-11T22:55:18+00:00

I am trying to create an application that will display images that are stored

  • 0

I am trying to create an application that will display images that are stored locally on the webserver. Here is what I have in my view, note that “entry” are absolute addresses like "C:\Images\Image1.jpg". However, when I run it, I get "Not allowed to load local resource: file:///C:/Images/ImageName.jpg" in the console log. So maybe it tries to access the image on the client. How do I tell my view to access the local webserver path and not look for the image source on the client? Please note that moving the images into project directory is not an option, because the images are stored on a different drive on the webserver.

<!-- language: c# -->
@model List<String>
<div style="height: 500px; overflow:scroll;">
<h2>
    ScreenShots for testMachine</h2>

@foreach (var entry in Model)
{          
   <div class="nailthumb-container square-thumb">
   <img alt="screenshot" src="@Url.Content(entry)" /> 

</div>
}
</div>
  • 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-11T22:55:19+00:00Added an answer on June 11, 2026 at 10:55 pm

    You cannot directly serve images outside of your ASP.NET MVC 3 application to the client. That would be a huge security vulnerability if the client could access arbitrary files on your server.

    You will need to write a controller action that will return them and then point your src property of your <img> tags to this controller action.

    public class ImagesController: Controller
    {
        public ActionResult SomeImage()
        {
            return File(@"C:\Images\foo.jpg", "image/jpeg");
        }
    }
    

    and inside your view:

    <img src="@Url.Action("SomeImage", "Images")" alt="" />
    

    You could also pass the image name as parameter to the controller action:

    public class ImagesController: Controller
    {
        public ActionResult SomeImage(string imageName)
        {
            var root = @"C:\Images\";
            var path = Path.Combine(root, imageName);
            path = Path.GetFullPath(path);
            if (!path.StartsWith(root))
            {
                // Ensure that we are serving file only inside the root folder
                // and block requests outside like "../web.config"
                throw new HttpException(403, "Forbidden");
            }
    
            return File(path, "image/jpeg");
        }
    }
    

    and in your view:

    <img src="@Url.Action("SomeImage", "Images", new { image = "foo.jpg" })" alt="" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a diagnostic log for my application that will display the
I am trying to create an application that will have a tray icon only,
I'm trying to create a fullscreen application that will hide the cursor to display
I'm trying to create an application that will display all restaurants within the users
Im trying to create a server/client application that will work on two or more
I'm trying to create an application in Java that will print an image based
I'm trying to make an Android application that will display a map of a
I am trying to create an application that will send out style-heavy emails and
I'm trying to create an application that will fetch data from a web API
I am trying to create BB application that features the in-app purchase. I followed

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.