bradjive
bradjive

Reputation: 1492

How do I decode a URL that was encoded with MVC's Url.Encode(string url)

I'm surprised the UrlHelper provides an encoder but not a decoder! Does anyone have the code for decoding or know where to find it in the MVC framework?

Upvotes: 21

Views: 30370

Answers (5)

HamedH
HamedH

Reputation: 3273

In ASP MVC Core use this:

WebUtility.UrlDecode(string encodedValue)

Upvotes: 1

naveen
naveen

Reputation: 61

HttpUtility.UrlDecode(Parameter);

Upvotes: 6

Donuts
Donuts

Reputation: 2251

Actually it should be HttpUtility.UrlDecode, not HttpServerUtility.

Upvotes: 49

user677686
user677686

Reputation: 308

An encoded url will automatically be decoded when passed into a controller action. For example:

public ActionResult Index(string url)
{
    //url will be decoded here
}

Upvotes: -4

Related Questions