ExecuteQuerySegmentedAsync是否可以在4.6.1中运行的WebForms中工作?

问题描述 投票:0回答:1

我有一个维护的旧Webforms应用程序。我需要访问一些我们现在存储在Azure表存储中的数据。该应用程序是针对4.6.1构建的,并引用WindowsAzure.Storage 9.3.3。假设有一个表和一个查询定义的帐户,当我运行以下代码时,第一个快速返回,而另一个挂起。如果我删除

<httpRuntime targetFramework="4.6.1" />

两组代码都返回。问题在于,如果不在4.6.1中运行,则默认为4.0,该版本不支持TLS 1.2。

代码:

TableContinuationToken token = null;
do
{
    var segment = cloudTable.ExecuteQuerySegmented<T>(tableQuery, token);
    token = segmentAsync.ContinuationToken;
} while (token != null);

token = null;
do
{
    var segmentAsync = await cloudTable.ExecuteQuerySegmentedAsync<T>(tableQuery, token);
    token = segmentAsync.ContinuationToken;
} while (token != null);
asp.net azure-table-storage hang .net-4.6.1
1个回答
1
投票

ExecuteQuerySegmentedAsync方法确实在.NET Framework 4.6.1中运行的WebForms中有效。

我正在使用WindowsAzure.Storage 9.3.3,并且没有删除<httpRuntime targetFramework="4.6.1" />,它可以工作。

注:这只是一个简单的测试代码,用以证明ExecuteQuerySegmentedAsync可以正常工作。如果仍有问题,请提供完整的代码。

Default.aspx.cs中的简单代码-> Page_Load方法:

using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using System;
using System.Web.UI;

namespace WebApplication15
{
    public partial class _Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            string connstr = "DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=xxx;EndpointSuffix=core.windows.net";
            var storageAccount = CloudStorageAccount.Parse(connstr);
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
            CloudTable table = tableClient.GetTableReference("test22");

            TableQuery<CustomerEntity> query =
                    new TableQuery<CustomerEntity>().Where(
                            TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "r1")
                        );

            TableContinuationToken token = null;
            do
            {
                var segment = table.ExecuteQuerySegmented<CustomerEntity>(query, token);
                token = segment.ContinuationToken;
            } while (token != null);

            token = null;
            do
            {
                var segmentAsync = table.ExecuteQuerySegmentedAsync<CustomerEntity>(query, token).GetAwaiter().GetResult();
                token = segmentAsync.ContinuationToken;
            } while (token != null);

        }

    }
}

结果:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.