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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:53:43+00:00 2026-05-12T18:53:43+00:00

I have an image gallery that I created by reading the contents inside a

  • 0

I have an image gallery that I created by reading the contents inside a directory. Now right away I noticed a problem when there was a “+” in the filename. Like “glas + door.jpg” would break. So I thought it was an encoding problem and since it was only the “+” sign I thought that replacing the “+” with “%2b” would solve the problem. Locally the problem was fixed but when I uploaded it to my host I noticed replacing the “+” sign with “%2b” didn’t work help anymore.

So this is where I started looking at the encoding possibilities of ASP.NET. I found Server.UrlEncode and Server.UrlPathEncode. This gave me some mixed results like images that worked before wouldn’t work anymore.

So what’s the correct way of encoding a path and why did the replace “trick” work on my PC but not in my hosting environment?

public List<fileInfo> RenderImages()
{
    List<fileInfo> RenderImages = new List<fileInfo>();
    var Images = GetImages();

    if (Images != null)
    {
        foreach (var Image in Images)
        {
            string FullPath = Path + FolderName + "/" + Image.Name.Replace("+", "%2b");
            string ImageName = Image.Name.Replace(Image.Extension, string.Empty);

            RenderImages.Add(new fileInfo { path = FullPath, name = ImageName });
        }
    }

    return RenderImages;
}    

public class fileInfo
{
    public string path { get; set; }
    public string name { get; set; }
}

The GetImages() function gets jpg, gif and png FileInfos from a certain directory. If needed, I can post that part of code also.

If it helps, here you can see how the images break. This is with Replace("+", "%2b").

Thanks in advance.

  • 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-12T18:53:43+00:00Added an answer on May 12, 2026 at 6:53 pm

    The problem is that space can be escaped as + in URL:s and there is no way for a server to tell if you really mean + or space. Even when encoded as %2b it might be a double encoded space, so it will still turn out as a space when decoded.

    To fix this, you can manually replace “+” with “%252b” instead, which will correctly decode as +.

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

Sidebar

Related Questions

As of right now, in my app I have created a rudimentary gallery app
I have an image gallery that is created using a repeater control. The repeater
I have an image gallery app that has a slider to control the width
I my working on the site that will have image gallery. Designer idea was
Does anyone have a suggestions for a superb cool image gallery that I can
what i want to do is that i have a nice image Gallery which
I have a PHP script that initialises an image gallery. It loops through all
I have photo gallery code that does image re-sizing and thumbnail creation. I use
I have a PHP script that creates a thumbnail and lists an image gallery.
I have a custom gallery plugin that I have created and I am wanting

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.