protected void Application_Start(object sender, EventArgs e) { var appHost = new AppHost(); appHost.Plugins.Add(new SessionFeature()); appHost.Plugins.Add(new SwaggerFeature()); #if DEBUG // Allow cross-site scripting for stand-alone development appHost.Plugins.Add(new CorsFeature( allowedMethods: "GET, POST, OPTIONS", allowedHeaders: "Origin, X-Requested-With, Content-Type, Accept, X-ApiKey, X-ss-pid, X-ss-opt")); #endif appHost.GlobalRequestFilters.Add( (req, res, dto) => { var localBypass = false; #if DEBUG localBypass = req.IsLocal; #endif if (localBypass) return; var attr = dto.GetType().GetCustomAttributes(typeof(AuthenticateAttribute), false); if (attr.Length <= 0) return; var apiKey = req.Headers["X-ApiKey"] ?? req.GetParam("X-ApiKey"); if (apiKey == null || apiKey != ConfigurationManager.AppSettings["APIKey"]) { throw HttpError.Unauthorized("Unauthorized"); } }); typeof(Resources).AddAttributes(new RestrictAttribute { VisibilityTo = RequestAttributes.None }); typeof(ResourceRequest).AddAttributes(new RestrictAttribute { VisibilityTo = RequestAttributes.None }); appHost.Init(); }
static void Main() { Cef.Initialize(new CefSettings()); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); AppHost = new AppHost(); AppHost.Init().Start("http://*:1337/"); "ServiceStack SelfHost listening at {0} ".Fmt(HostUrl).Print(); Form = new FormMain(); Application.Run(Form); }
static void Main(string[] args) { LogManager.LogFactory = new ConsoleLogFactory(); var listeningOn = args.Length == 0 ? "http://*:8090/" : args[0]; var appHost = new AppHost(); appHost.Init(); appHost.Start(listeningOn); Console.WriteLine("AppHost Created at {0}, listening on {1}", DateTime.Now, listeningOn); Console.ReadKey(); }
static void Main(string[] args) { var appHost = new AppHost(); appHost.Init(); appHost.Start(ListeningOn); Console.WriteLine("Started listening on: " + ListeningOn); Console.WriteLine("AppHost Created at {0}, listening on {1}", DateTime.Now, ListeningOn); Process.Start(ListeningOn); Console.WriteLine("ReadKey()"); Console.ReadKey(); }