Odpowiedzi:
Server.UrlDecode(xxxxxxxx)
System.Web.HttpServerUtilityBase, ale to powinno być już zaimportowane w ASP.NET MVC.
string decodedUrl = Uri.UnescapeDataString(url)
lub
string decodedUrl = HttpUtility.UrlDecode(url)
Adres URL nie jest w pełni odkodowany przy jednym wywołaniu. Aby w pełni zdekodować, możesz wywołać jedną z tych metod w pętli:
private static string DecodeUrlString(string url) {
string newUrl;
while ((newUrl = Uri.UnescapeDataString(url)) != url)
url = newUrl;
return newUrl;
}
Uri.UnescapeDataStringdwa razy i dostałem to, czego chciałem! : D
Czy próbowałeś HttpServerUtility.UrlDecodelub HttpUtility.UrlDecode?
HttpServerUtility.UrlDecodektóra jest instancją, należy użyć HttpContext.Current.Server.UrlDecode.
Próbować:
var myUrl = "my.aspx?val=%2Fxyz2F";
var decodeUrl = System.Uri.UnescapeDataString(myUrl);