【发布时间】:2017-03-23 07:06:51
【问题描述】:
我正在尝试向天蓝色表存储添加一行。这是我第一次使用这个,所以我遵循了一个 MS 教程,不幸的是他们使用控制台应用程序而不是 MVC,所以我不得不即兴发挥一点,基本上,当我将 [httpPost] 添加到我的 AddRow 方法时,我得到了一个 http 404 错误 “'/' 应用程序中的服务器错误。找不到资源。”
代码(在 HomeController 内):
[HttpPost]
public ActionResult AddRow()
{
ViewBag.Message = "Your application description page.";
try
{
CloudStorageAccount cloudStorageAcc = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
CloudTableClient cloudTableClient = cloudStorageAcc.CreateCloudTableClient();
CloudTable table = cloudTableClient.GetTableReference("Users");
table.CreateIfNotExists();
Insert inserter1 = new Insert("Bob", "Contoso");
inserter1.UserName = "Bobbie";
TableOperation insertOperation = TableOperation.Insert(inserter1);
table.Execute(insertOperation);
}
catch
{
return View();
}
return View();
}
我尝试通过 mysite.azurewebsites.net/Home/AddRow
访问它【问题讨论】:
标签: asp.net-mvc azure asp.net-mvc-5 azure-table-storage