【发布时间】:2016-09-19 04:42:24
【问题描述】:
我在 Visual Studio 上创建了一个 Azure 云服务项目。我已经能够将我的文件上传到 azure blob 存储中。我需要的是,当单击一个按钮时,它会返回我上传的 blob 的 URL,例如 http://127.0.0.1:10000/devstoreaccount1/conversions/filename.extension
在我看来,我做了以下事情:
<div class="table">
<table class="table table-responsive">
<thead>
<tr>
<th>File Name</th>
<th>ConversionID</th>
<th>Actual Format</th>
<th>Status</th>
<th>Download</th>
</tr>
</thead>
@foreach (var item in Model)
{
<tr>
<td>@item.FileName</td>
<td>@item.ConversionID</td>
<td>@item.Format</td>
<td>@item.Status</td>
<td>
<a href="/Download.aspx?conversionID=@item.ConversionID">
<span class="DownloadListItem">
<b>Download<b>
</span>
</a>
</tr>
}
</table>
</div>
我的下载.aspx.cs:
private ApplicationDbContext db = new ApplicationDbContext();
protected void Page_Load(object sender, EventArgs e)
{
string rawId = Request.QueryString["ConversionID"];
int converionID;
if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out converionID))
{
var v = db.Conversions.Where(a => a.ConversionID.Equals(converionID));
if (v != null)
{
//return ConversionURL
}
}
else
{
Debug.Fail("ERROR : We should never get to AddToCart.aspx without a ConversionID.");
throw new Exception("ERROR : It is illegal to load AddToCart.aspx without setting a ConversionID.");
}
}
如何在我的代码中返回 ConversionURL?
编辑
当我上传文件时,我将文件及其内容上传到 Azure Blob 存储中,但我还将上传文件的 ConversionID 和 ConversionURL 存储在 SQL 服务器数据库中。
【问题讨论】:
-
您需要告诉我们您的conversionID与您上传的文件有何关联。
-
刚刚编辑了我的帖子!
标签: c# asp.net-mvc azure blob