問題描述
我在 AngularJs 應(yīng)用程序中遇到了有線問題.當(dāng)用戶嘗試登錄應(yīng)用時,如果密碼中包含與號 (&),則無法驗證用戶.
I am having a wired issue in my AngularJs application. When user is trying to login to the app and if the password contains ampersand (&), then it couldn't able to validate the user.
我正在使用 OWIN、oAuth2.0 JWT 令牌來驗證我的 Asp.Net Web API.
I am using OWIN, oAuth2.0 JWT token to validate my Asp.Net Web APIs.
當(dāng)我調(diào)試時,我發(fā)現(xiàn)如果密碼包含 & 符號 (&),那么它會截斷 & 符號 (&) 中的所有字符.
When i debug i found that if the password contains ampersand (&), then it is truncating all the characters from ampersand (&).
例如,如果密碼為x&x",則 OAuthValidateClientAuthenticationContext 上下文只會獲取密碼值中的x".
For example, if the password is 'x&x' the OAuthValidateClientAuthenticationContext context is getting only 'x' in password value.
我附上了問題的屏幕截圖點擊查看問題..
I have attached a screen shot of the issue click to see the issue..
對此問題的任何幫助,我們將不勝感激.
Any help on this issue, would be highly appreciated.
推薦答案
我猜測該值被解釋為查詢字符串分隔符.
Am guessing the value is being interpreted as a query string separator.
嘗試使用javascript方法
Try using the javascript method
encodeURI()
或者
EncodeURIcomponent()
在發(fā)布到服務(wù)器之前你的密碼值,所以和號變成了
On your password value before posting to the server, so the ampersand becomes
&
服務(wù)器將為您解碼.
如果您不這樣做,您可能會發(fā)現(xiàn)斜杠和問號在密碼中也不起作用
The server will decode this for you.
You'll probably find that slashes and question marks will also not work in passwords if you dont
這篇關(guān)于Asp.Net Web API oAuth 2.0 無法使用包含與號 (&) 的密碼進行驗證的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!