我有一个非常奇怪的错误,想知道是否有人知道其原因。
当我创建分别名为 Content 和 ContentController 的新 DataObject 和 TableController 时,它不会注册表 Controller ,并且它自动生成的帮助文档已丢失其样式。
我根本无法连接到 Controller ,但所有其他 Controller 都按预期工作。
如果我只是将其重命名为 DataController,这只是 Controller 的名称,而不是数据对象的名称,一切都会完美运行。
ContentController 是某种保留字还是只是发生在我的机器上?
public class DataController : TableController<Content>
{
protected override void Initialize(HttpControllerContext controllerContext)
{
base.Initialize(controllerContext);
MobileContext context = new MobileContext();
DomainManager = new EntityDomainManager<Content>(context, Request, Services);
}
// GET tables/Content
public IQueryable<Content> GetAllContent()
{
return Query();
}
// GET tables/Content/48D68C86-6EA6-4C25-AA33-223FC9A27959
public SingleResult<Content> GetContent(string id)
{
return Lookup(id);
}
// PATCH tables/Content/48D68C86-6EA6-4C25-AA33-223FC9A27959
public Task<Content> PatchContent(string id, Delta<Content> patch)
{
return UpdateAsync(id, patch);
}
// POST tables/Content/48D68C86-6EA6-4C25-AA33-223FC9A27959
public async Task<IHttpActionResult> PostContent(Content item)
{
Content current = await InsertAsync(item);
return CreatedAtRoute("Tables", new { id = current.Id }, current);
}
// DELETE tables/Content/48D68C86-6EA6-4C25-AA33-223FC9A27959
public Task DeleteContent(string id)
{
return DeleteAsync(id);
}
}
最佳答案
MVC 项目将创建一个名为 Content 的应用程序目录。这将 override您的路由映射到 ContentController。
如果desired,您可以解决这个问题通过更改 RouteMaps 和其他技巧,尽管最简单的答案可能是更改 Controller 的名称...
关于azure - 特定的 TableController 名称不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25737244/