在Windows Phone 8中我有方法public async Task<bool> authentication()
.函数的返回类型是bool
但当我尝试在if
条件错误中使用其返回值时表示无法转换Task<bool>
为bool
.
public async Task<bool> authentication()
{
var pairs = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string> ("user", _username),
new KeyValuePair<string, string> ("password", _password)
};
var serverData = serverConnection.connect("login.php", pairs);
RootObject json = JsonConvert.DeserializeObject<RootObject>(await serverData);
if (json.logined != "false")
{
_firsname = json.data.firsname;
_lastname = json.data.lastname;
_id = json.data.id;
_phone = json.data.phone;
_ProfilePic = json.data.profilePic;
_thumbnail = json.data.thumbnail;
_email = json.data.email;
return true;
}
else
return …
Run Code Online (Sandbox Code Playgroud) 我正在使用HttpUtility.UrlEncode()
字符串令牌,原始令牌是t+Bj/YpH6zE=
当HttpUtility.UrlDecode()
它变为t Bj/YpH6zE=
打破算法时.是一种停止在c#中将+更改为空格的方法.
我目前正在使用replace方法来实现这一点 var token_decrypt = HttpUtility.UrlDecode(token).Replace(" ", "+");
public HttpResponseMessage RegisterUser(User user, string token)
{
int accID;
if(string.IsNullOrWhiteSpace(token))
{
return Request.CreateResponse(HttpStatusCode.BadRequest);
}
else
{
try
{
// token now = t Bj/YpH6zE= which will fail
var token_decrypt = HttpUtility.UrlDecode(token);
token now = t Bj/YpH6zE= still the same
accID = int.Parse(Crypto.Decrypt(token_decrypt, passPhrase));
}
catch
{
return Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid account ");
}
Run Code Online (Sandbox Code Playgroud)
她编码令牌
string encoded_token = HttpUtility.UrlEncode(token);
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
SmtpClient …
Run Code Online (Sandbox Code Playgroud)