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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:30:30+00:00 2026-06-12T16:30:30+00:00

Visual Studio 2012 – ASP.net – MVC 4 I am having troubles displaying an

  • 0

Visual Studio 2012 – ASP.net – MVC 4

I am having troubles displaying an image from a server path which is stored in a database.

I am using HttpPostedFileBase to retrieve the file the user has uploaded:

using (var uow = _db.CreateUnitOfWork())
            {
                if (imageUpload != null && imageUpload.ContentLength > 0)
                {
                    var fileName = Path.GetRandomFileName() + Path.GetExtension(imageUpload.FileName);
                    var path = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~/Uploads"), fileName);
                    imageUpload.SaveAs(path);
                    achievement.ImageLoc = path;
                }

                uow.Add(achievement);
                Save(uow);
                return true;
            }

This will save the absolute path of the uploaded file into the database and save the file onto the server. When I try to retrieve this path to display an image file in a view all I get is a blank square like the file is not being found (about:blank when right click -> copy image url). I know the path is correct because I am using it in a different view to allow users to download files, which is working correctly. Also I am allowing the user to edit the file which successfully deletes the old and uploads a new one. The only problem I am having is displaying an image in a view.

I have tried:

<img src="@Html.Encode(Model.ImageLoc)" />
<img src=@Url.Content(Model.ImageLoc)" />

Would anyone be able to suggest anything?

  • 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-12T16:30:32+00:00Added an answer on June 12, 2026 at 4:30 pm

    You have stored the absolute path to the image in your database, but you need to reference it with the relative path:

    <img src="@Url.Content("~/Uploads/" + System.IO.Path.GetFileName(Model.ImageLoc))" alt="" />
    

    The resulting HTML must look like this:

    <img src="/Uploads/tccxdfu0.nde.jpg" alt="" />
    

    and not:

    <img src="\\PDC2\sites\t\<site.co.uk>\public_html\Uploads\tccxdfu0.nde.jpg" alt="" />
    

    because the client cannot access such folders from the server.

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

Sidebar

Related Questions

Using Visual Studio 2012, I created a new ASP.NET MVC 4 web project, using
I use Visual Studio 2012 to create ASP.NET Webpages. To improve my sheet styles
I'm running Visual Studio 2012 RC with the .Net 4.5 bits with T4MVC. I'm
I am using the Visual Studio Publish Web screen to publish my ASP.Net to
Visual Studio 2008/2010/ASP.NET: How to speed up the delay after rebuilding the solution? I
I have SQL Server 2012, SSIS, SSDT and Visual Studio 2010. I can create
i´m trying to use the asp.net web api in WEB FORMS with visual studio
Using C#, .NET 4, SQL, visual studio 2010 and sql server manager 2008. Hi
Using: Visual Studio 2012, .NET Framework 4, Windows 7 x64 Sometimes, upon starting my
In the Visual Studio 2012 RC, I can't install Web Developer Tools properly. None

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.