为了账号安全,请及时绑定邮箱和手机立即绑定

将国旗图像与国家名称匹配:

将国旗图像与国家名称匹配:

C#
SMILET 2021-10-24 14:22:32
我有一个下拉菜单,其中包含提交给数据库的国家/地区名称。我想在最终用户个人资料上显示该国国旗的图像。我在根目录中有一个包含所有标志图标的文件夹。我该怎么办?我能够获取用户的国家/地区名称,但现在我可以使用该名称从图像文件夹中获取图像。 Flag_image.ImageUrl = "~/images/"countryTESTLabel.Text.ToString.Replace("_", " ")".png";
查看完整描述

2 回答

?
饮歌长啸

TA贡献1951条经验 获得超3个赞

我有同样的问题,但没有解决方案。我将其追溯到函数中MobileServiceHttpClient代码中的以下代码行SendRequestAsync(...)。


// If there was supposed to be response content and there was not, throw        

if (ensureResponseContent)

{

   long? contentLength = null;


   if (response.Content != null)

   {

      contentLength = response.Content.Headers.ContentLength;

   }


   if (contentLength == null || contentLength <= 0)

   {

        throw new MobileServiceInvalidOperationException("The server did not provide a response with the expected content.", request, response);

   }

}

看着response.Content.Headers.ContentLength它是null。将应用程序作为 2.0 Core 项目运行,该值已正确填写。奇怪的是内容在那里。


如果您深入了解私有成员,其中一些已正确设置。


catch (MobileServiceInvalidOperationException msioe)

{

    //content will contain the correct json but the ContentLenth is null!?!

    string content = await msioe.Response.Content.ReadAsStringAsync();


}

这是一个 2.1 核心问题。希望他们修复它。


查看完整回答
反对 回复 2021-10-24
  • 2 回答
  • 0 关注
  • 176 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信