Asp.Net Web API oAuth 2.0 cannot validate with password containing ampersand (amp;)(Asp.Net Web API oAuth 2.0 无法使用包含与号 (amp;) 的密码进行验证)
问题描述
我在 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 无法使用包含与号 (&) 的密码进行验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Asp.Net Web API oAuth 2.0 无法使用包含与号 (&
基础教程推荐
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
