【发布时间】:2019-08-01 19:49:13
【问题描述】:
我正在尝试从 Azure Blob 填充数据(带有超链接的文件名)。
这是我的代码:
更新面板:
<asp:UpdatePanel ID="up1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="refreshButton" runat="server" Text="Refresh" OnClick="refreshButton_Click" />
<asp:ListView ID="fileDisplayControl" runat="server">
<LayoutTemplate>
<asp:Hyperlink ID="itemPlaceholder" runat="server" />
</LayoutTemplate>
<ItemTemplate>
<asp:Hyperlink ID="filehyperlink" runat="server" NavigateUrl='<%# Eval("Url") %>' />
</ItemTemplate>
</asp:ListView>
</ContentTemplate>
</asp:UpdatePanel>
在 Listview 中,我放置了 HYperlink 控件,其中数据填充有超链接。
向 Listview 控件提供数据源的代码:
private CloudBlobContainer getfileGalleryContainer()
{
return _blobStorageService.getCloudBlobContainer();
}
protected void Page_PreRender(object sender, EventArgs e)
{
try
{
// Blob container that contains the ppp
// Perform a query of the its contents and return the list of all of the blobs whose name begins with the string "ppp".
// It returns an enumerator of their URLs and place that enumerator into list view as its data source.
fileDisplayControl.DataSource =
from o in getfileGalleryContainer().GetDirectoryReference("ppp").ListBlobs()
select new { Url = o.Uri };
// List view to bind to its data source
fileDisplayControl.DataBind();
}
catch (Exception)
{
}
}
不幸的是,即使文件存储在 ppp blob 中,也没有填充任何内容。
有人请告诉我这个过程有什么问题吗?
【问题讨论】:
-
你检查有没有
exceptions? -
不要出现任何异常。 Web-job 正在运行并生成文件,但没有任何结果
-
如果这是真实的代码,你不会看到异常,因为
catch(Exception) { }去掉try/catch,再试一次。 -
它无法在本地 Blob 中创建任何内容,这可能是一个原因。即使它在 Azure 中发布并运行,它也会在 Azure 存储 blob 中创建文件,但不会在 LIstview 中返回任何内容。它没有显示任何错误令人惊讶
标签: c# asp.net asp.net-mvc azure-storage