![](/img/trans.png)
[英]What is the equivalent of JavaScript's decodeURIcomponent in PHP?
[英]Is there any equivalent to JavaScript's decodeURIComponent() in C#?
我正在使用Angular 7開發Ionic應用程序。不幸的是,當用戶使用' + '登錄密碼時遇到問題。 在Angular post請求中,“ + ”號被空格代替。
我在stackoverflow中找到了一些解決方案,並使用了JavaScript的encodeURIComponent()來對密碼進行編碼。 它將“ +”符號轉換為“%2B”。
但是,在我的API中找不到任何解碼器來解碼' %2B '到' + '符號。 注意,我的服務器端是用ASP.NET(C#)編寫的。 或者,有沒有辦法發送帶有' + '號的密碼而不轉換為' %2B '
'content-type': 'application/x-www-form-urlencoded'
示例密碼 : 'abc+123'
不帶 encodeURIComponent()
: 'abc 123'
帶 encodeURIComponent()
: 'abc%2B123'
您可以在服務器端以這種方式嘗試:
string encodedValue="abc%2B123";
string decodedvalue= Uri.UnescapeDataString(encodedValue);
Console.WriteLine(decodedvalue);
-- or
string encodedValue1=HttpUtility.HtmlEncode("abc+123");
string decodedValue1 = HttpUtility.HtmlDecode(encodedValue1);
Console.WriteLine(decodedValue1);
謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.