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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:51:59+00:00 2026-05-26T19:51:59+00:00

So I started a little home project in MVC 3 where I need to

  • 0

So I started a little home project in MVC 3 where I need to make a photo gallery.

I’ve been following a guide where I have been creating an Image folder inside my Content folder in where I’ve placed 2 pictures and also an xml file which contains a path and a description for each picture.

The XML is then loaded in from the filesystem into a XDocument and delivered to the View.

The view is then supposed to foreach through each image (Has 2 properties, path and description) and insert this path into an HTML src property and a href property.

I can see that the paths are delivered correctly, such as img1.png, to the view. However I have a problem getting the paths to work an display the picture. I think that href and the src cannot interpret the property strings correctly.

Or could it be that I need a relative path or Url.Content encode?

Here is the view

@foreach(var item in Model){
 <div>
   <a href="content/images/@item.path">
     <img src="content/images/@item.path"/>
   </a>
   <span>
    @item.description
   </span
</div>

I hope I’ve explained it properly else don’t hesitate to ask for more information.

My plan is to have a page that contains these pictures and then use the jQuery Ligthbox to be able to magnify the pictures and easily view through the picture.

  • 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-05-26T19:52:00+00:00Added an answer on May 26, 2026 at 7:52 pm

    Relative path won’t work here. Because of the routed path. For instance your current url is mydomain.com/Gallery/All and your image path given content/images/@item.path which will return mydomain.com/Gallery/All/content/images/@item.path and definitely your image is not in that location.

    For this you the easier way is to use Url.Content like this:

    @foreach(var item in Model){
     <div>
       <a href="@Url.Content("~/content/images/" + item.path)">
         <img src="@Url.Content("~/content/images/" + item.path)" />
       </a>
       <span>
        @item.description
       </span
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've started working on a little ruby project that will have sample implementations of
I've just started a project and need a little push in the right direction.
Intro I'm developing a project with MVC.Net. I have just started a default website
Since I've started making a little project aiming to have a crossplatform support, I
Started learning Wicket after ASP.NET MVC and feel a little bit confused about managing
I started using emacs and slime to develop some little service. I have found
I just started out with C and have very little knowledge about performance issues
I've started a little project for myself to get more familiar and comfortable with
I recently started a little project in PHP, I'm sort of new to this
I started little project with Play Framework 2.0 and I wonder which is the

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.