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 7837585

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:42:22+00:00 2026-06-02T14:42:22+00:00

Background : I’m trying to some some URL manipulation for an MVC application. I’ve

  • 0

Background: I’m trying to some some URL manipulation for an MVC application. I’ve written an HtmlHelper extension method that replaces on query string value with another. The method takes the current request string, manually splits the query part (so as to prevent Foo=1&Foo=Hello%2c%20World!&Foo=2 from being read as Foo=1,Hello, World,2), and then tries to use UriBuilder and Uri to get a URL.

Problem: For some reason, Uri.ToString partially decodes query strings. As a quick test, I fired up LINQPad and ran the following:

var ub = new System.UriBuilder("http://foobar");
ub.Query = "NY%26A"; // NY&A
ub.Uri.Dump();
ub.Uri.ToString().Dump();
ub.Uri.Query.Dump();
ub.ToString().Dump();

The results are:

http://foobar/?NY&A
http://foobar/?NY&A
?NY%26A
http://foobar:80/?NY%26A

I say partially decoding, because if I use lots of escaped characters, it decodes some and leaves others in place:

var ub = new System.UriBuilder("http://foobar");
ub.Query = "!%40%23%24%25%5E%26*()"; // !@#$%^&*()
ub.Uri.Dump();
ub.Uri.ToString().Dump();
ub.Uri.Query.Dump();
ub.ToString().Dump();

And the results:

http://foobar/?!@%23$%25^&*()
http://foobar/?!@%23$%25^&*()
?!%40%23%24%25%5E%26*()
http://foobar:80/?!%40%23%24%25%5E%26*()

Question: Can someone explain what is going on?

  • 0 0 Answers
  • 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

Sidebar

Related Questions

background: I work on an asp.net web application that is on a company intranet.
Background: Some time ago, I built a system for recording and categorizing application crashes
Background: Our web app uses the jquery.constrain.js plugin to handle data entry in some
Background I have a dimension table that has a single record for each day.
Background, Part 1 I have a form that collects both frequency and duration from
Background: I have this with rollup query defined in MySQL: SELECT case TRIM(company) when
Background: I'm writing a 'standard' (nothing special) web application in Ruby (not Rails) and
Background I have an existing extension designed to accompany a browser-based game (The extension
Background: I have a css and a js that is used only by the
Background I have a ror application which is continuously recording and showing on a

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.