c# – 字符串长度超过32768个字符时的Azure存储异常
发布时间:2020-12-15 23:49:22 所属栏目:百科 来源:网络整理
导读:我的应用程序是ASP.NET Core 1.0 Web API.如果我的控制器返回一个小字符串,一切正常.但是如果字符串长度超过32768,我收到以下错误消息: --- End of stack trace previous location where exception was thrown ---?? at System.Runtime.CompillerServices.T
我的应用程序是ASP.NET Core 1.0 Web API.如果我的控制器返回一个小字符串,一切正常.但是如果字符串长度超过32768,我收到以下错误消息:
--- End of stack trace previous location where exception was thrown --- ?? at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task) ?? at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) ?? at Microsoft.AspNetCore.Server.Kestrel.Internal.Htpp.Frame`1.<RequestProcessAsync>d__2.MoveNext() Request Information RequestID:440ed7db-0002-006f-742e-a28f82000000 RequestDate:Tue,21 Mar 2017 11:30:40 GMT StatusMessage:Bad Request ErrorCode:PropertyValueTooLarge 这是我的控制器: [HttpGet] [Produces("plain/text")] public async Task<IActionResult> GetData() { return this.Ok(this.GetResponse()); } private string GetResponse() { string retVal = string.Empty; for (int i = 0; i < 32769; i++) { retVal = retVal + "a"; } return retVal; } 完整的错误消息: Microsoft.WindowsAzure.Storage.StorageException: BadRequest at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.<ExecuteAsyncInternal>d__4`1.MoveNext() in C:Program Files (x86)Jenkinsworkspacerelease_dotnet_masterLibWindows RuntimeCoreExecutorExecutor.cs:line 315 --- End of stack trace previous location where exception was thrown --- at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompillerServices.TaskAwaiter`1.GetResult() at MyProjectNameLogging.AzureStorageLoggingConnector.<WriteToRequestLogAsync>d__4.MoveNext() in AzureStorageLoggingTable.cs:line 29 --- End of stack trace previous location where exception was thrown --- at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompillerServices.TaskAwaiter.GetResult() at MyProjectNameLogging.Repositories.RequestLoggingRepository.<WriteToLogAsync>d__6.MoveNext() in RepositoriesRequestLoggingRepository.cs:line 36 --- End of stack trace previous location where exception was thrown --- at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompillerServices.TaskAwaiter.GetResult() at MyProjectNameLogging.Middleware.RequestMiddleware.<Invoke>d__2.MoveNext() in MiddlewareRequestMiddleware.cs:line 69 --- End of stack trace previous location where exception was thrown --- at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Swashbuckle.SwaggerUi.Application.SwaggerUiMiddleware.<Invoke>d__5.MoveNext() --- End of stack trace previous location where exception was thrown --- at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Swashbuckle.SwaggerUi.Application.RedirectMiddleware.<Invoke>d__4.MoveNext() --- End of stack trace previous location where exception was thrown --- at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Swashbuckle.Swagger.Application.SwaggerMiddleware.<Invoke>d__6.MoveNext() --- End of stack trace previous location where exception was thrown --- at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext() --- End of stack trace previous location where exception was thrown --- at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext() --- End of stack trace previous location where exception was thrown --- at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext() --- End of stack trace previous location where exception was thrown --- at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext() --- End of stack trace previous location where exception was thrown --- at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext() --- End of stack trace previous location where exception was thrown --- at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext() --- End of stack trace previous location where exception was thrown --- at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext() --- End of stack trace previous location where exception was thrown --- at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext() --- End of stack trace previous location where exception was thrown --- at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext() --- End of stack trace previous location where exception was thrown --- at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext() --- End of stack trace previous location where exception was thrown --- at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext() --- End of stack trace previous location where exception was thrown --- at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext() --- End of stack trace previous location where exception was thrown --- at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.<Invoke>d__7.MoveNext() --- End of stack trace previous location where exception was thrown --- at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.<Invoke>d__8.MoveNext() --- End of stack trace previous location where exception was thrown --- at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Server.Hosting.Internal.RequestServiceContainerMiddleware.<Invoke>d__3.MoveNext() --- End of stack trace previous location where exception was thrown --- ?? at System.Runtime.CompillerServices.TaskAwaiter.ThrowForNonSuccess(Task task) ?? at System.Runtime.CompillerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) ?? at Microsoft.AspNetCore.Server.Kestrel.Internal.Htpp.Frame`1.<RequestProcessAsync>d__2.MoveNext() Request Information RequestID:6d8afaf4-0002-00cd-1235-a2421e000000 RequestDate:Tue,21 Mar 2017 12:24:57 GMT StatusMessage:Bad Request ErrorCode:PropertyValueTooLarge 我想返回长度超过32768的字符串. 有什么建议吗? 解决方法
您遇到字符串属性类型(
source)的Azure存储限制:
因为UTF-16编码的字符串需要2个字节来存储字符,所以最大字符串长度为32768个字符. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |