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); }
//Run it! static void Main(string[] args) { GlobalData.HostSettings = RetrieveSettings(); var listeningOn = args.Length == 0 ? "http://*:8888/" : args[0]; var appHost = new AppHost() .Init() .Start(listeningOn); Console.WriteLine("AppHost Created at {0}, listening on {1}", DateTime.Now, listeningOn); Console.ReadKey(); }
/// <summary> /// Defines the entry point of the application. /// </summary> /// <param name="args">The arguments.</param> private static void Main(string[] args) { var listeningOn = args.Length == 0 ? "http://*:1337/" : args[0]; var appHost = new AppHost() .Init() .Start(listeningOn); Logger.LogMessage("AppHost Created at {0}, listening on {1}", DateTime.Now, listeningOn); Task.Factory.StartNew(SomerBlinkStateMachine.RunPromoCheck, TaskCreationOptions.LongRunning); Console.ReadLine(); Console.Write("Preparing to cancel..."); Console.ReadLine(); }
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(); }
static void Main(string[] args) { var app = new AppHost(); app.Start(); Process.Start(app.URL); //JsonServiceClient client = new JsonServiceClient(app.URL); //var response = client.Get<HttpWebResponse>("/json/reply/OrderRequestDto"); /* ServiceStack */ Console.WriteLine("Following tests are done using ServiceStack serializer"); Console.WriteLine(); Print("TEST: Buyer attached to each order:"); SendRequest(app.URL + "json/reply/OrderRequestDto?AttachBuyerToOrder=true"); Console.WriteLine(); Print("TEST: Buyer was not set to order (need assembler):"); SendRequest(app.URL + "json/reply/OrderRequestDto?AttachBuyerToOrder=false"); /* JSON.NET */ Console.WriteLine(); Console.WriteLine("Following tests are done using JSON.NET serializer"); Console.WriteLine(); JsConfig<OrderResponseDto>.RawSerializeFn = t => JsonConvert.SerializeObject(t); JsConfig<OrderResponseDto>.RawDeserializeFn = t => JsonConvert.DeserializeObject<OrderResponseDto>(t); Print("TEST: Buyer attached to each order:"); SendRequest(app.URL + "json/reply/OrderRequestDto?AttachBuyerToOrder=true"); Console.WriteLine(); Print("TEST: Buyer was not set to order (need assembler):"); SendRequest(app.URL + "json/reply/OrderRequestDto?AttachBuyerToOrder=false"); "Press any key to exit...".Print(); Console.ReadLine(); }