user161433
user161433

Reputation: 4519

ASP.NET MVC -- How to Format URL Query String

How to I format a query string so it looks like this

search?q=power+tools

currently it looks like this

search?q=power%20tools

Is there a way to do this without replacing the space for a plus sign?

Upvotes: 0

Views: 2401

Answers (2)

Richard Szalay
Richard Szalay

Reputation: 84724

Not really. HttpUtility.UrlEncode encodes it that way, and that is what is used by pretty much everything in ASP.NET.

Besides, from memory %20 is actually correct for query strings, and + is correct for URLs. Ignore this, it's incorrect.

Upvotes: 0

Tadas Šukys
Tadas Šukys

Reputation: 4220

HttpServerUtility.UrlDecode

In a ASP.NET page HttpServerUtility instance can be accessed by Page.Server property.

Upvotes: 1

Related Questions