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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:51:25+00:00 2026-06-03T06:51:25+00:00

In my MVC applciation, sometimes I’m creating my querystring dynamically: once from javascript, and

  • 0

In my MVC applciation, sometimes I’m creating my querystring dynamically: once from javascript, and once from c# server code. In javascript, I’m using encodeURIComponent(value), and from the c#, I’m using HttpUtility.UrlEncode(value) method from System.Web

Suppose, I have space in the value, ex: a q:

  • encodeURIComponent(value) returns a%20q
  • HttpUtility.UrlEncode(value) returns a+q

Space is encoded differently, using these two methods. Is that any reason why is it working this way, different that “it was written like that long time ago and stays untouched” ?

Additionally, suppose I have plus in the value, ex: a+q

  • encodeURIComponent(value) returns a%2Bq
  • HttpUtility.UrlEncode(value) returns a%2bq

The js method returns upper case encoded characters, while c# one returns lower case ones.

What is the best way to cooperate in parallel with these two methods, to make the application behave in coherent way ? Shall I write alternative c# method to imitate the js method behaviour ? I suppose the decoding methods has the same differences. Is there any “correct” way work with these ?

  • 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-03T06:51:27+00:00Added an answer on June 3, 2026 at 6:51 am

    Percent-encoding is defined in RFC3986. It defines that a space character is encoded as %20. However, query strings are most often in application/x-www-form-urlencoded format, which also allows encoding spaces as + instead of %20. If the decoder expects the query string in this format, then an encoder can choose whichever it prefers.

    You can use the Uri.EscapeDataString Method if you want spaces always to be encoded as %20:

    var result = Uri.EscapeDataString("a q");
    // result == "a%20q"
    

    On upper-case vs lower-case, RFC3986 says:

    The uppercase hexadecimal digits ‘A’ through ‘F’ are equivalent to
    the lowercase digits ‘a’ through ‘f’, respectively. If two URIs
    differ only in the case of hexadecimal digits used in percent-encoded
    octets, they are equivalent.

    For consistency, URI producers and
    normalizers should use uppercase hexadecimal digits for all
    percent-encodings.

    var result = Uri.EscapeDataString("a+q");
    // result == "a%2Bq"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that developed using j2ee and Struts 2 MVC. Sometimes
I'm using MVC 3 and using the following code when the application starts... UnityContainer
In my ASP.NET MVC application I want a user to add a value into
I deployed my MVC application in our IIS server. When I go to registration
In my ASP.NET MVC application i am using Chinese Category Name, it was displayed
I am using subsonic to access my DB in a mvc application. When trying
I'm developing a web application using asp.net Mvc 2 and NHibernate, and I'm paging
I have a strange issue with an Asp.NET MVC application. Using Asp.NET MVC 3
I have an ASP.NET MVC 3 application with a SQL Server 2005 database backend.
I have a spring mvc application and we run tests with it using jetty.

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.