我最近将后端项目从WindowsAzure.MobileServices.Backend更改为Microsoft.Azure.Mobile.Server。在新的'项目类型似乎在我的控制器方法上装饰的RouteAttribute
不起作用。以下是配置的外观:
public partial class Startup
{
public static void ConfigureMobile(IAppBuilder app)
{
var config = new HttpConfiguration();
new MobileAppConfiguration()
.UseDefaultConfiguration()
.ApplyTo(config);
config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
config.Formatters.JsonFormatter.SerializerSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Include;
config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Include;
config.MapHttpAttributeRoutes();
var settings = config.GetMobileAppSettingsProvider().GetMobileAppSettings();
if (string.IsNullOrEmpty(settings.HostName))
{
app.UseAppServiceAuthentication(new AppServiceAuthenticationOptions
{
SigningKey = ConfigurationManager.AppSettings["SigningKey"],
ValidAudiences = new[] { ConfigurationManager.AppSettings["ValidAudience"] },
ValidIssuers = new[] { ConfigurationManager.AppSettings["ValidIssuer"] },
TokenHandler = config.GetAppServiceTokenHandler()
});
}
app.UseWebApi(config);
}
}
RouteAttribute
再次正常工作需要什么?
答案 0 :(得分:3)
我认为这是一个订购问题。在将MobileAppConfiguration应用于HttpConfiguration之前,应调用config.MappHttpAttributeRoutes()
。