Asp.Net Web API oAuth 2.0无法使用包含与号(&)的密码进行验证 [英] Asp.Net Web API oAuth 2.0 cannot validate with password containing ampersand (&)

查看:63
本文介绍了Asp.Net Web API oAuth 2.0无法使用包含与号(&)的密码进行验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的AngularJs应用程序中出现有线问题.当用户尝试登录该应用程序时,如果密码包含&"号,则它将无法验证用户.

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.

当我调试时,我发现如果密码包含&"号,那么它将截断&"号中的所有字符.

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()

在发布到服务器之前输入您的密码值,因此&符将变为

On your password value before posting to the server, so the ampersand becomes

&

服务器将为您解码.
您可能会发现,如果不这样做,斜杠和问号也将无法在密码中使用

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

这篇关于Asp.Net Web API oAuth 2.0无法使用包含与号(&)的密码进行验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆