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

  • Home
  • SEARCH
  • 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 6962047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:36:33+00:00 2026-05-27T15:36:33+00:00

I few years ago I created a database driven ASP.NET site, which uses a

  • 0

I few years ago I created a database driven ASP.NET site, which uses a single APSX page to display all site pages. So all the URLs of the site are in the following format:

/main.aspx?page=Page+Title+One

/main.aspx?page=Another+Article+Title

/main.aspx?page=Third+Page

The main.aspx page gets the query string data (Page+Title+One for example) and uses it as a key to pull the appropriate article content from the SQL server database. The actual title of the page is stored in the db with spaces instead of pluses (for example “Page Title One”).

The poor decision to go with the + sign as a word separator in the URL query string is causing lots of issues with search engines lately (duplicate content, etc.), so I want to fix it, but without changing URLs.

What I want to do is when search engine or visitor tries to visit the wrong URL missing the + signs and having white spaces instead, for example:

/main.aspx?page=Page Title One

I want to do 301 permanent redirect to:

/main.aspx?page=Page+Title+One

To be able to do this I need to check if the query string value has pluses or white spaces, however when I get the value with Request.QueryString[“page”] even if the actual quesry string has pluses in it I still get string with white spaces “Page Title One”.

The site runs on IIS6/Win 2003.

How can I do this?

  • 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-27T15:36:34+00:00Added an answer on May 27, 2026 at 3:36 pm

    Well, of course you can’t put a space in a URI in any case. What you can do is put %20 in which is the way to encode a space at any point in a URI as well as + being the normal way to encode a space in the query portion, and the recommended way to do so in that portion of it because %20 can cause problems.

    Because of this is an implementaiton detail application/x-www-form-urlencoded and we normally care about the actual data sent, Request.QueryString[] does the unescaping for you, turning both + and %20 into a space.

    You want to look at the Request.RawUrl (returns a string) or Request.Url which returns a Uri. Probably the easiest is to feed Request.Url into a UriBuilder so you can change just the query and get a Uri back.

    Still, I’d recommend the opposite approach, if you’re having issues with duplicate content due to the two possible ways of encoding a space in the query string, go with the recommended norm and turn the cases of %20 into + rather than the other way around.

    var u = Request.Url;
    if(u.Query.Contains("%20"))
    {
        var ub = new UriBuilder(u);
        Console.WriteLine(ub.Query);
        string query = ub.Query;
        //note bug in Query property - it includes ? in get and expects it not to be there on set
        ub.Query = ub.Query.Replace("%20", "+").Substring(1);
        Response.StatusCode = 301;
        Response.RedirectLocation = ub.Uri.AbsoluteUri;
        Response.End();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A few years ago there was a bug involving ASP.NET and Tortoise/AnkhSvn (can't remember
A few years ago, when first being introduced to ASP.net and the .NET Framework,
A few years ago I developed a web app for which we wanted to
A few years ago I created a simple app to track my daily status.
A few years ago I installed a CMS which was written in PHP. This
A few years ago I used the Hibernate ORM for mapping database data to
Few years ago (2005), a colleague created a VS2005 project an Web Application and
We created a website few years ago and it worked all well except we
A few years ago I used a simple display/pixel drawing library in C++ to
A few years ago, I read a book that described how you could override

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.