Skip to content

Instantly share code, notes, and snippets.

@yuka1984
Last active December 15, 2016 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuka1984/7739da28ff6d90e1258661dc4ab6b1cd to your computer and use it in GitHub Desktop.
Save yuka1984/7739da28ff6d90e1258661dc4ab6b1cd to your computer and use it in GitHub Desktop.
public static void ConfigureMobileApp(IAppBuilder app)
{
HttpConfiguration config = new HttpConfiguration();
/*
new MobileAppConfiguration()
.UseDefaultConfiguration()
.ApplyTo(config);
*/
new MobileAppConfiguration()
.AddTables(
new MobileAppTableConfiguration()
.MapTableControllers()
.AddEntityFramework()
)
.MapApiControllers()
.AddPushNotifications()
//.AddMobileAppHomeController()
.ApplyTo(config);
// Use Entity Framework Code First to create database tables based on your DbContext
Database.SetInitializer(new MobileServiceInitializer());
MobileAppSettingsDictionary settings = config.GetMobileAppSettingsProvider().GetMobileAppSettings();
if (string.IsNullOrEmpty(settings.HostName))
{
app.UseAppServiceAuthentication(new AppServiceAuthenticationOptions
{
// This middleware is intended to be used locally for debugging. By default, HostName will
// only have a value when running in an App Service application.
SigningKey = ConfigurationManager.AppSettings["SigningKey"],
ValidAudiences = new[] { ConfigurationManager.AppSettings["ValidAudience"] },
ValidIssuers = new[] { ConfigurationManager.AppSettings["ValidIssuer"] },
TokenHandler = config.GetAppServiceTokenHandler()
});
}
app.UseWebApi(config);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment