Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用空用户名/唯一密码的Windows.Web.Http身份验证_C# - Fatal编程技术网

C# 使用空用户名/唯一密码的Windows.Web.Http身份验证

C# 使用空用户名/唯一密码的Windows.Web.Http身份验证,c#,C#,我是开发Windows10通用应用程序的新手。我需要使用空/空用户名和密码通过Windows.Web.Http进行身份验证。如果我使用空字符串或null,则在创建凭据时会出现异常 有什么想法吗?好的,我自己有: 首先,我尝试使用(空用户名引发无效参数异常): 现在我正在使用: var buffer = Windows.Security.Cryptography.CryptographicBuffer.ConvertStringToBinary(username + ":" + pass, Win

我是开发Windows10通用应用程序的新手。我需要使用空/空用户名和密码通过
Windows.Web.Http
进行身份验证。如果我使用空字符串或null,则在创建凭据时会出现异常


有什么想法吗?

好的,我自己有:

首先,我尝试使用(空用户名引发无效参数异常):

现在我正在使用:

var buffer = Windows.Security.Cryptography.CryptographicBuffer.ConvertStringToBinary(username + ":" + pass, Windows.Security.Cryptography.BinaryStringEncoding.Utf8);

在收到异常时,最好包含异常类型和消息。
var buffer = Windows.Security.Cryptography.CryptographicBuffer.ConvertStringToBinary(username + ":" + pass, Windows.Security.Cryptography.BinaryStringEncoding.Utf8);