AuthenticationHeaderValue没有“Scheme” [英] AuthenticationHeaderValue without "Scheme"

查看:935
本文介绍了AuthenticationHeaderValue没有“Scheme”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。

我需要设置"AuthenticationHeaderValue"" "HttpClient"的"HttpClient"。请求。问题是使用代码:

I need to set the "AuthenticationHeaderValue" of a "HttpClient" request. The problem is that usign the code:

request.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic" , string.Format("{0}:{1}", userID, authorizationCrypted));

结果是这样的:

授权=基本afñlvnasd:fiakbmañsdknfñaoewgbnadslvai

Authorization= Basic afñlvnasd:fiakbmañsdknfñaoewgbnadslvai

问题是我的REST服务正在等待没有此"方案"的授权标头。所以"基本"是不应该在那里。如何使用授权标题发送我的请求,其中只有我的encripted字符串?

The problem is that my REST service is waiting for the Authorization header without this "Scheme" so the "basic" shouldn't be there. How can I send my request with a Authorization header where only goes my encripted string?

谢谢

推荐答案

这有用吗?



请求
DefaultRequestHeaders 授权
= AuthenticationHeaderValue ""
字符串 格式 " {0}:{1}" userID authorizationCrypted ));
$


您明确传入了"基本",这就是为什么它在那里。 如果这不起作用,那么您应该只能添加自己的自定义标题。
Does this work?

request
.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("" , string.Format("{0}:{1}", userID, authorizationCrypted));

You explicitly passed in "Basic", so that's why it's there.  If that does not work, then you should be able to just add your own custom header in any case.


这篇关于AuthenticationHeaderValue没有“Scheme”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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