Asp.net mvc Azure移动应用程序服务-StorageController路由不工作
当我们点击TableController时,移动服务工作正常。但是,即使为StorageController类型的控制器设置了所有必需的参数和配置,我们也无法与它们连接 当我们尝试调用这些GET方法时(例如:{id}/MobileServiceFile) 我们得到以下回应: 您正在查找的资源已被删除、名称已更改或暂时不可用 我们怀疑这些控制器上的路由是否正常工作或是否被移动服务接收,需要帮助修复 以下是应用程序的启动配置:Asp.net mvc Azure移动应用程序服务-StorageController路由不工作,asp.net-mvc,asp.net-web-api,azure-mobile-services,azure-web-app-service,Asp.net Mvc,Asp.net Web Api,Azure Mobile Services,Azure Web App Service,当我们点击TableController时,移动服务工作正常。但是,即使为StorageController类型的控制器设置了所有必需的参数和配置,我们也无法与它们连接 当我们尝试调用这些GET方法时(例如:{id}/MobileServiceFile) 我们得到以下回应: 您正在查找的资源已被删除、名称已更改或暂时不可用 我们怀疑这些控制器上的路由是否正常工作或是否被移动服务接收,需要帮助修复 以下是应用程序的启动配置: new MobileAppConfiguration()
new MobileAppConfiguration()
.MapApiControllers()
.AddTables( // from the Tables package
new MobileAppTableConfiguration()
.MapTableControllers()
.AddEntityFramework() // from the Entity package
)
.ApplyTo(config);
我们无法调用的存储控制器类之一(尝试使用PostMan-Get请求)
使用System.Collections.Generic;
使用System.Net.Http;
使用System.Threading.Tasks;
使用System.Web.Http;
使用Microsoft.Azure.Mobile.Server.Files;
使用Microsoft.Azure.Mobile.Server.Files.Controller;
使用FieldEngineer.DataObjects;
名称空间FieldEngineer.控制器
{
[授权]
[RoutePrefix(“表格/新的监控数据”)]
公共类新\u监控\u数据存储控制器:StorageController
{
[HttpPost]
[路由(“{id}/StorageToken”)]
公共异步任务PostStorageTokenRequest(字符串id,StorageTokenRequest值)
{
StorageToken token=等待GetStorageTokenAsync(id,值);
返回请求.CreateResponse(令牌);
}
//获取与此记录关联的文件
[HttpGet]
[路由(“{id}/MobileServiceFiles”)]
公共异步任务GetFiles(字符串id)
{
IEnumerable files=等待GetRecordFilesAsync(id);
返回请求.CreateResponse(文件);
}
[HttpDelete]
[路由(“{id}/MobileServiceFiles/{name}”)]
公共任务删除(字符串id、字符串名称)
{
返回base.DeleteFileAsync(id,name);
}
}
}
您是否执行了config.maphttpAttribute路由()代码>在启动文件中?您是否执行了config.maphttpAttribute路由()代码>在启动文件中?公共部分类启动{public static void ConfigureMobileApp(IAppBuilder应用程序){HttpConfiguration config=new HttpConfiguration();config.EnableSystemDiagnosticsTracing();new MobileAppConfiguration().UseDefaultConfiguration().ApplyTo(config);Database.SetInitializer(null);app.UseWebApi(config);所以不。它是否在“new MobileAppConfiguration().UseDefaultConfiguration().ApplyTo(config)”之后;我通常将它放在MobileAppConfiguration()之前。但我认为这并不重要。谢谢,我让它工作了,但我接受了培训,但在我的表名中加下划线,这是另一个问题。Azure SQL SaaS何时会更像常规SQL?公共部分类启动{public static void ConfigureMobileApp(IAppBuilder应用程序){HttpConfiguration config=new-HttpConfiguration();config.EnableSystemDiagnosticsTracing();new-MobileAppConfiguration().UseDefaultConfiguration().ApplyTo(配置);Database.SetInitializer(null);app.UseWebApi(配置);那么它后面是什么“new MobileAppConfiguration().UseDefaultConfiguration().ApplyTo(config);”我通常将其放在MobileAppConfiguration()之前。但我认为这并不重要。谢谢,我已经让它工作了,但我接受了培训,可以在我的表名中添加下划线,这是另一个问题。Azure SQL SaaS何时会更像常规SQL?
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.Azure.Mobile.Server.Files;
using Microsoft.Azure.Mobile.Server.Files.Controllers;
using FieldEngineer.DataObjects;
namespace FieldEngineer.Controllers
{
[Authorize]
[RoutePrefix("tables/New_Monitoring_Data")]
public class New_Monitoring_DataStorageController : StorageController<New_Monitoring_Data>
{
[HttpPost]
[Route("{id}/StorageToken")]
public async Task<HttpResponseMessage> PostStorageTokenRequest(string id, StorageTokenRequest value)
{
StorageToken token = await GetStorageTokenAsync(id, value);
return Request.CreateResponse(token);
}
// Get the files associated with this record
[HttpGet]
[Route("{id}/MobileServiceFiles")]
public async Task<HttpResponseMessage> GetFiles(string id)
{
IEnumerable<MobileServiceFile> files = await GetRecordFilesAsync(id);
return Request.CreateResponse(files);
}
[HttpDelete]
[Route("{id}/MobileServiceFiles/{name}")]
public Task Delete(string id, string name)
{
return base.DeleteFileAsync(id, name);
}
}
}