简体   繁体   English

ASP.Net Core 2.1上的Azure移动后端连接问题

[英]Azure Mobile Backend connection issue on ASP.Net Core 2.1

I am working on an ASP.Net Core web app and I try to connect it via an Azure Mobile Backend. 我正在使用ASP.Net Core Web应用程序,尝试通过Azure移动后端将其连接。

The backend is working well with other Windows Desktop applications. 后端可以与其他Windows桌面应用程序很好地协作。 Also the backend was working well till now with ASP.Net Core v2.0. 到目前为止,后端与ASP.Net Core v2.0的运行情况都很好。 Yesterday I installed the ASP.Net Core 2.1 SDK and I updated the Microsoft.AspNetCore.All nuget package from 2.0 to 2.1.2 and since then I am receiving the following exception: MobileServiceInvalidOperationException - "The server did not provide a response with the expected content." 昨天我安装了ASP.Net Core 2.1 SDK,并将Microsoft.AspNetCore.All nuget软件包从2.0更新到2.1.2,此后,我收到以下异常:MobileServiceInvalidOperationException-“服务器未提供预期的响应内容。”

Can you tell me any solution to solve this issue? 您能告诉我解决这个问题的任何解决方案吗?

Also the backend was working well till now with ASP.Net Core v2.0. 到目前为止,后端与ASP.Net Core v2.0的运行情况都很好。 Yesterday I installed the ASP.Net Core 2.1 SDK and I updated the Microsoft.AspNetCore.All nuget package from 2.0 to 2.1.2 and since then I am receiving the following exception: MobileServiceInvalidOperationException - "The server did not provide a response with the expected content." 昨天我安装了ASP.Net Core 2.1 SDK,并将Microsoft.AspNetCore.All nuget软件包从2.0更新到2.1.2,此后,我收到以下异常:MobileServiceInvalidOperationException-“服务器未提供预期的响应内容。”

According to your description, your Azure Mobile Backend could work as expected with ASP.Net Core v2.0. 根据您的描述,您的Azure移动后端可以与ASP.Net Core v2.0一起正常工作。 AFAIK, mobile backend just provides a simple way for you to expose your Table/API endpoints. AFAIK,移动后端只是为您提供公开Table / API端点的简单方法。 Moreover, how did your web app connect with mobile backend, using HttpClient or Azure Mobile Client SDK ? 此外,您的Web应用如何使用HttpClient或Azure Mobile Client SDK与移动后端连接?

For a simple way to troubleshoot this issue, you could Enable diagnostics logging for your Azure Mobile App to retrieve the detailed error message to narrow this issue, details you could follow here . 作为解决此问题的简单方法,可以为Azure移动应用启用诊断日志记录以检索详细的错误消息以缩小此问题的范围,您可以在此处关注详细信息。

I have the same issue but no solution. 我有同样的问题,但没有解决方案。 I traced it down to the following line of code in MobileServiceHttpClient code in the SendRequestAsync(...) function. 我在SendRequestAsync(...)函数中将其SendRequestAsync(...) MobileServiceHttpClient代码的以下代码行。

// 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);
   }
}

Looking at the response.Content.Headers.ContentLength it is null . 查看response.Content.Headers.ContentLength它为null Running the app as a 2.0 Core project, the value is filled in correctly. 将应用程序作为2.0核心项目运行时,该值已正确填写。 What is is strange is that the content is there. 奇怪的是内容在那里。

If you drill into the private members some of them are set correctly. 如果您深入研究私有成员,则其中一些成员的设置正确。

catch (MobileServiceInvalidOperationException msioe)
{
    //content will contain the correct json but the ContentLenth is null!?!
    string content = await msioe.Response.Content.ReadAsStringAsync();

}

It is a 2.1 Core issue. 这是一个2.1核心问题。 Hopefully they fix it. 希望他们修复它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM