public static void Main(string[] args) { var step = fu.Map.Controller(new NotesController()); var app = new WebApp(step); app.Start(); }
private void OnBeginRequest(object sender, EventArgs e) { if (!_initialized) { lock (_lock) { if (!_initialized) { var webApp = new WebApp(); webApp.Startup(); context.Disposed += (oo, ee) => { webApp.NotifyExit(); }; _initialized = true; } } } }
/// <summary> /// 程序入口方法 /// </summary> /// <param name="args">传入静态文件地址和网站地址(先后有序)</param> private static void Main(string[] args) { int len = args.Length; if (len <= 0) { path = Environment.CurrentDirectory; local = "http://localhost:8181"; } else if (len == 1) { if (string.IsNullOrWhiteSpace(args[0])) { path = Environment.CurrentDirectory; } else { path = args[0]; } local = "http://localhost:8181"; } else { if (string.IsNullOrWhiteSpace(args[0])) { path = Environment.CurrentDirectory; } else { path = args[0]; } if (string.IsNullOrWhiteSpace(args[1])) { local = "http://localhost:8181"; } else { local = args[1]; } } Console.WriteLine(local); Console.WriteLine(path); try { //var startOpts = new StartOptions(local) { }; var startOpts = new StartOptions(); startOpts.Urls.Add(local); //startOpts.Urls.Add(local.Replace("localhost","127.0.0.1")); using (WebApp.Start <Startup>(startOpts)) { Console.WriteLine("Server run at " + local + " , press Enter to exit."); System.Diagnostics.Process.Start("explorer.exe", local); string input = string.Empty; do { input = Console.ReadLine(); } while (input != "exit"); Console.WriteLine("Server has stopped, press Enter to exit."); Console.ReadKey(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void Start() { _webApp = WebApp.Start <StartOwin>("http://localhost:9000"); }
/// <summary> [區] /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// <Author>Wei-Ru.Hong</Author> protected void ddlArea_SelectedIndexChanged(object sender, EventArgs e) { this.ddlLot.DataSource = WebApp.GetDatas("SELECT distinct 地段名稱, 地段號 FROM AREADATA WHERE ID= " + this.ddlArea.SelectedValue + " Order by 地段號"); this.ddlLot.DataBind(); }
private static string GetConnectionStringsXml(WebApp currentApp) { var connections = currentApp.ConnectionStrings.Select(MapConnectionString); return(string.Join(Environment.NewLine, connections.ToArray())); }
public FrmConfigXml(WebApp currentApp) { _currentApp = currentApp; InitializeComponent(); }
static void Main(string[] args) { if (Player != null) { Console.WriteLine("Server is already running!"); } // react to close window event and cleanup _handler += new EventHandler(Handler); SetConsoleCtrlHandler(_handler, true); Player = new Player(); Player.LoadUserConfig("Data/UsersConfig.json"); Player.LoadRadioConfig("Data/Radios.json"); Player.LoadStatus("Data/PlayerStatus.json"); Player.LoadYoutubeHistory("Data/YoutubeHistory.json"); string serverUrl = ConfigurationManager.AppSettings["Bindings"] ?? "http://*:80"; try { using (WebApp.Start <Startup>(serverUrl)) { Console.WriteLine($"Server running at {serverUrl}"); Console.Write("Enter command: "); bool notExit = true; while (notExit) { // read command and clear that console line string commandString = Console.ReadLine(); Console.SetCursorPosition(0, Console.CursorTop - 1); Console.Write(new string(' ', Console.BufferWidth)); Console.SetCursorPosition(0, Console.CursorTop - 1); // call player to handle commands Player.HandleCommand(commandString, new Models.Client { Name = "Server" }); // got exit command, so exit server if (commandString == "exit") { Player.Hub.Clients.All.ConsoleLog("Server closed. Refresh browser."); break; } } } } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message + ex.InnerException?.Message); } finally { if (Player != null) { Player.SaveStatus(); Player.Dispose(); Player = null; } } Console.SetCursorPosition(0, Console.CursorTop); Console.WriteLine("Server closed. Press any key to exit..."); Console.ReadKey(); }
/// <summary> /// This method is called when the service gets a request to start. /// </summary> /// <param name="args">Any command line arguments</param> public void OnStart(string[] args) { //TODO: Make sure you have a "endpoint" appsetting (or use a different means of supplying this value to WebApp.Start() //TODO: Also make sure the url is registered (netsh http add urlacl url=http://+:8080/ user=DOMAIN\USER) or you run this as administrator/local system account _server = WebApp.Start <WebAppStartup>(ConfigurationManager.AppSettings["endpoint"]); }
protected override void OnStart(string[] args) { _server = WebApp.Start <Startup>(url: baseAddress); Logger.INFO(MethodBase.GetCurrentMethod(), "Server running on " + baseAddress); }
public void Start() { m_application = WebApp.Start <Startup>(ConfigurationManager.AppSettings.Get("SelfHostUrl")); }
static void Main(string[] args) { WebApp.Start <Startup>("http://localhost:5000/"); Console.ReadLine(); }
public void Start() { _webserver = WebApp.Start <Startup>("http://localhost:5000"); HangfireTaskFactory.CreateJobs(); }
protected override void OnStartup(object sender, System.Windows.StartupEventArgs e) { // need ADMIN or add urlacl. _Server = WebApp.Start("http://*:18685"); DisplayRootViewFor <IShell>(); }
public void Start() { _server = WebApp.Start(Url); }
public override void BeforeEach() { _webServer = WebApp.Start <TestStartup>("http://*:5555"); ServiceProxy = new MemberApiProxy("http://localhost:5555"); }
public override void Dispose() { lock (this) { base.Dispose (); if (_server != null) _server.Dispose (); if (_app != null) _app.Dispose (); if (_sessionMiddleware != null) _sessionMiddleware.Dispose (); _server = null; _app = null; _sessionMiddleware = null; } }
public void Initialize() { _webApi = WebApp.Start <Startup>(url: _address); }
public void Start() { _web = WebApp.Start(_options, app => new StartUp(_options).Configuration(app)); }
protected override void OnStart(string[] args) { _owinHost = WebApp.Start <Startup>(Address); }
protected override void OnStart(string[] args) { string url = "http://localhost:8080"; WebApp.Start(url); }
public AppStack() { var config = new Config(); var resourceGroup = new ResourceGroup("rotatesecretoneset-rg"); var sqlAdminLogin = config.Get("sqlAdminLogin") ?? "sqlAdmin"; var sqlAdminPassword = new RandomUuid("sqlPassword").Result; var sqlServer = new Server("sqlServer", new ServerArgs { AdministratorLogin = sqlAdminLogin, AdministratorLoginPassword = sqlAdminPassword, ResourceGroupName = resourceGroup.Name, Version = "12.0", }); new FirewallRule("AllowAllWindowsAzureIps", new FirewallRuleArgs { ServerName = sqlServer.Name, ResourceGroupName = resourceGroup.Name, StartIpAddress = "0.0.0.0", EndIpAddress = "0.0.0.0", }); var clientConfig = Output.Create(GetClientConfig.InvokeAsync()); var tenantId = clientConfig.Apply(c => c.TenantId); var storageAccount = new StorageAccount("storageaccount", new StorageAccountArgs { Kind = "Storage", ResourceGroupName = resourceGroup.Name, Sku = new Storage.Inputs.SkuArgs { Name = "Standard_LRS" }, }); var appInsights = new Component("appInsights", new ComponentArgs { RequestSource = "IbizaWebAppExtensionCreate", ResourceGroupName = resourceGroup.Name, ApplicationType = "web", Kind = "web", Tags = { //{ "[concat('hidden-link:', resourceId('Microsoft.Web/sites', parameters('functionAppName')))]", "Resource" }, }, }); var secretName = config.Get("secretName") ?? "sqlPassword"; var appService = new AppServicePlan("functionApp-appService", new AppServicePlanArgs { ResourceGroupName = resourceGroup.Name, Sku = new SkuDescriptionArgs { Name = "Y1", Tier = "Dynamic", }, }); var storageKey = ListStorageAccountKeys.Invoke(new ListStorageAccountKeysInvokeArgs { AccountName = storageAccount.Name, ResourceGroupName = resourceGroup.Name }).Apply(t => t.Keys[0].Value); var functionApp = new WebApp("functionApp", new WebAppArgs { Kind = "functionapp", ResourceGroupName = resourceGroup.Name, ServerFarmId = appService.Id, Identity = new ManagedServiceIdentityArgs { Type = ManagedServiceIdentityType.SystemAssigned }, SiteConfig = new SiteConfigArgs { AppSettings = { new NameValuePairArgs { Name = "AzureWebJobsStorage", Value = Output.Format($"DefaultEndpointsProtocol=https;AccountName={storageAccount.Name};AccountKey={storageKey}"), }, new NameValuePairArgs { Name = "FUNCTIONS_EXTENSION_VERSION", Value = "~3", }, new NameValuePairArgs { Name = "FUNCTIONS_WORKER_RUNTIME", Value = "dotnet", }, new NameValuePairArgs { Name = "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING", Value = Output.Format($"DefaultEndpointsProtocol=https;AccountName={storageAccount.Name};EndpointSuffix=core.windows.net;AccountKey={storageKey}"), }, new NameValuePairArgs { Name = "WEBSITE_NODE_DEFAULT_VERSION", Value = "~10", }, new NameValuePairArgs { Name = "APPINSIGHTS_INSTRUMENTATIONKEY", Value = appInsights.InstrumentationKey, }, }, }, }); var functionAppSourceControl = new WebAppSourceControl("functionApp-sourceControl", new WebAppSourceControlArgs { Name = functionApp.Name, IsManualIntegration = true, Branch = "main", RepoUrl = config.Get("functionAppRepoURL") ?? "https://github.com/Azure-Samples/KeyVault-Rotation-SQLPassword-Csharp.git", ResourceGroupName = resourceGroup.Name, }); var webAppAppService = new AppServicePlan("webApp-appService", new AppServicePlanArgs { ResourceGroupName = resourceGroup.Name, Sku = new SkuDescriptionArgs { Name = "F1", }, }); var webApp = new WebApp("webApp", new WebAppArgs { Kind = "app", ResourceGroupName = resourceGroup.Name, ServerFarmId = webAppAppService.Id, Identity = new ManagedServiceIdentityArgs { Type = ManagedServiceIdentityType.SystemAssigned }, }); var keyVault = new Vault("keyVault", new VaultArgs { Properties = new VaultPropertiesArgs { AccessPolicies = { new AccessPolicyEntryArgs { TenantId = tenantId, ObjectId = functionApp.Identity.Apply(i => i !.PrincipalId), Permissions = new PermissionsArgs { Secrets ={ "get", "list", "set" }, }, },
private static string GetAppSettingsXml(WebApp currentApp) { var settingStrings = currentApp.AppSettings.Select(a => $"<add key=\"{a.Key}\" value=\"{a.Value}\" />"); return(string.Join(Environment.NewLine, settingStrings.ToArray())); }
static void Main(string[] args) { WebApp.Start <Startup>("http://localhost:8080"); Console.WriteLine("Server Started; Press enter to Quit"); Console.ReadLine(); }
public void Start(string baseAddress) { runningServices = new List <IDisposable>(); runningServices.Add(WebApp.Start <Startup>(url: baseAddress)); }
public static void BeforeTestRun() { var url = ConfigurationManager.AppSettings["WebAPI.Test.ServerBaseURL"]; WebApp.Start <Startup>(url); }
/// <summary> [段] /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// <Author>Wei-Ru.Hong</Author> protected void ddlLot_SelectedIndexChanged(object sender, EventArgs e) { this.ddlAreaNumb.DataSource = WebApp.GetDatas("SELECT 地號 FROM AREADATA WHERE 地段號= " + this.ddlLot.SelectedValue + "Order by 地號"); this.ddlAreaNumb.DataBind(); }
/// <summary> /// Starts the web api /// </summary> public void Start() { _logger.Debug($"Starting web server on address: {_address}"); _webApp = WebApp.Start <Startup>(_address); }
/// <summary> /// Starts this UPnP server, i.e. starts a network listener and sends notifications about provided devices. /// </summary> /// <param name="advertisementInterval">Interval in seconds to repeat UPnP advertisements in the network. /// The UPnP architecture document (UPnP-arch-DeviceArchitecture-v1 1-20081015, 1.2.2, page 21) states a /// minimum of 1800 seconds. But in the world of today, that value is much to high for many applications and in many /// cases, a value of much less than 1800 seconds is choosen. For servers which will frequently change their /// availability, this value should be short, for more durable serves, this interval can be much longer (maybe a day).</param> public void Bind(int advertisementInterval = UPnPConsts.DEFAULT_ADVERTISEMENT_EXPIRATION_TIME) { lock (_serverData.SyncObj) { if (_serverData.IsActive) { throw new IllegalCallException("UPnP subsystem mustn't be started multiple times"); } //var port = _serverData.HTTP_PORTv4 = NetworkHelper.GetFreePort(_serverData.HTTP_PORTv4); var servicePrefix = "/MediaPortal/UPnPServer_" + Guid.NewGuid().GetHashCode().ToString("X"); _serverData.ServicePrefix = servicePrefix; var startOptions = BuildStartOptions(servicePrefix); IDisposable server = null; try { try { server = WebApp.Start(startOptions, builder => { builder.Use((context, func) => HandleHTTPRequest(context)); }); UPnPConfiguration.LOGGER.Info("UPnP server: HTTP listener started on addresses {0}", String.Join(", ", startOptions.Urls)); _serverData.HTTPListeners.Add(server); } catch (Exception ex) { if (UPnPConfiguration.IP_ADDRESS_BINDINGS?.Count > 0) { UPnPConfiguration.LOGGER.Warn("UPnP server: Error starting HTTP server with filters. Fallback to no filters", ex); } else { throw ex; } server?.Dispose(); startOptions = UPnPServer.BuildStartOptions(servicePrefix, new List <string>()); server = WebApp.Start(startOptions, builder => { builder.Use((context, func) => HandleHTTPRequest(context)); }); UPnPConfiguration.LOGGER.Info("UPnP server: HTTP listener started on addresses {0}", String.Join(", ", startOptions.Urls)); _serverData.HTTPListeners.Add(server); } } catch (SocketException e) { server?.Dispose(); UPnPConfiguration.LOGGER.Warn("UPnPServer: Error starting HTTP server", e); } _serverData.SSDPController = new SSDPServerController(_serverData) { AdvertisementExpirationTime = advertisementInterval }; _serverData.GENAController = new GENAServerController(_serverData); InitializeDiscoveryEndpoints(); NetworkChange.NetworkAddressChanged += OnNetworkAddressChanged; _serverData.IsActive = true; // At the end, start the controllers _serverData.SSDPController.Start(); _serverData.GENAController.Start(); UPnPConfiguration.LOGGER.Info("UPnP server online hosting {0} UPnP root devices", _serverData.Server.RootDevices.Count); } }
static void Main(string[] args) { WebApp.Start <Startup>("http://localhost:3333/"); Console.ReadLine(); // block main thread }
static Task <int> Main(string[] args) { return(Deployment.RunAsync(() => { var config = new Config(); var botName = config.Require("botName"); var resourceGroup = new ResourceGroup("botservice-rg"); var storageAccount = new Storage.Account("sa", new Storage.AccountArgs { ResourceGroupName = resourceGroup.Name, AccountReplicationType = "LRS", AccountTier = "Standard" }); var appServicePlan = new Plan("asp", new PlanArgs { ResourceGroupName = resourceGroup.Name, Kind = "App", Sku = new PlanSkuArgs { Tier = "Basic", Size = "B1" }, }); var container = new Storage.Container("zips", new Storage.ContainerArgs { StorageAccountName = storageAccount.Name, ContainerAccessType = "private", }); var blob = new Storage.ZipBlob("zip", new Storage.ZipBlobArgs { StorageAccountName = storageAccount.Name, StorageContainerName = container.Name, Type = "block", Content = new FileArchive("bot/publish") }); var codeBlobUrl = SharedAccessSignature.SignedBlobReadUrl(blob, storageAccount); var appInsights = new Insights("ai", new InsightsArgs { ApplicationType = "web", ResourceGroupName = resourceGroup.Name }); var appInsightApiKey = new ApiKey("ai", new ApiKeyArgs { ApplicationInsightsId = appInsights.Id, ReadPermissions = "api", }); var luis = new Cognitive.Account("cs", new Cognitive.AccountArgs { Kind = "CognitiveServices", // includes LUIS ResourceGroupName = resourceGroup.Name, Sku = new AccountSkuArgs { Name = "S0", Tier = "Standard" } }); var msa = new Application("msapp", new ApplicationArgs { Oauth2AllowImplicitFlow = false, AvailableToOtherTenants = true, PublicClient = true }); var pwd = new RandomPassword("password", new RandomPasswordArgs { Length = 16, MinNumeric = 1, MinSpecial = 1, MinUpper = 1, MinLower = 1 }); var msaSecret = new ApplicationPassword("msasecret", new ApplicationPasswordArgs { ApplicationObjectId = msa.ObjectId, EndDateRelative = "8640h", Value = pwd.Result }); var app = new AppService("app", new AppServiceArgs { ResourceGroupName = resourceGroup.Name, AppServicePlanId = appServicePlan.Id, AppSettings = { { "WEBSITE_RUN_FROM_PACKAGE", codeBlobUrl }, { "MicrosoftAppId", msa.ApplicationId }, { "MicrosoftAppPassword", msaSecret.Value }, { "LuisApiKey", luis.PrimaryAccessKey }, }, HttpsOnly = true }); var bot = new WebApp(botName, new WebAppArgs { DisplayName = botName, MicrosoftAppId = msa.ApplicationId, ResourceGroupName = resourceGroup.Name, Sku = "F0", Location = "global", Endpoint = Output.Format($"https://{app.DefaultSiteHostname}/api/messages"), DeveloperAppInsightsApiKey = appInsightApiKey.Key, DeveloperAppInsightsApplicationId = appInsights.AppId, DeveloperAppInsightsKey = appInsights.InstrumentationKey }); return new Dictionary <string, object> { { "Bot Endpoint", bot.Endpoint }, { "MicrosoftAppId", msa.ApplicationId }, { "MicrosoftAppPassword", msaSecret.Value } }; })); }
public static IDisposable CreateServer(string url) { return(WebApp.Start <SelfHostFactory.SelfHostStartup>(url: url)); }
DebugNode(int idx, Interrupters ints, ITcpListener listener, IDatagramEventSocket bindedDgramSock, IPEndPoint bindTcpEp, IPEndPoint bindUdpEp, int gw_port, string dbpath) : base(ints, bindedDgramSock, listener, dbpath, (ushort)bindUdpEp.Port, (ushort)bindTcpEp.Port) { _idx = idx; _bindTcpEP = bindTcpEp; _imPrivateKey = ECKeyPair.Create (DefaultAlgorithm.ECDomainName); _imPublicKey = Key.Create (_imPrivateKey); _name = "Node-" + idx.ToString ("x"); _app = new WebApp (this, ints); _is_gw = gw_port > 0; if (_is_gw) { _sessionMiddleware = new SessionMiddleware (MMLC.CreateDBConnection, _app); _server = HttpServer.CreateEmbedHttpServer (_sessionMiddleware, null, true, true, false, gw_port, 16); } }
public void Start() { var serviceConfig = SharedUtils.ServiceConfigManager.GetAppServiceConfig(); serviceConfig.ServiceFaultMsg = ""; if (serviceConfig.UseHTTPS) { // ensure self signed cert available on required port if (InstallSelfSignedCert(serviceConfig.Host, serviceConfig.Port)) { Program.LogEvent(null, $"Local service certificate installed ok", false); } else { Program.LogEvent(null, $"Local service certificate installed failed", false); } } var serviceUri = $"{(serviceConfig.UseHTTPS ? "https" : "http")}://{serviceConfig.Host}:{serviceConfig.Port}"; try { _webApp = WebApp.Start <APIHost>(serviceUri); Program.LogEvent(null, $"Service API bound OK to {serviceUri}", false); } catch (Exception exp) { var httpSysStatus = DiagnoseServices(); var msg = $"Service failed to listen on {serviceUri}. :: {httpSysStatus} :: Attempting to reallocate port. {exp.ToString()}"; Program.LogEvent(exp, msg, false); // failed to listen on service uri, attempt reconfiguration of port. serviceConfig.UseHTTPS = false; var currentPort = serviceConfig.Port; var newPort = currentPort += 2; var reconfiguredServiceUri = $"{(serviceConfig.UseHTTPS ? "https" : "http")}://{serviceConfig.Host}:{newPort}"; try { // if the http listener cannot bind here then the entire service will fail to start _webApp = WebApp.Start <APIHost>(reconfiguredServiceUri); Program.LogEvent(null, $"Service API bound OK to {reconfiguredServiceUri}", false); // if that worked, save the new port setting serviceConfig.Port = newPort; System.Diagnostics.Debug.WriteLine($"Service started on {reconfiguredServiceUri}."); } catch (Exception) { serviceConfig.ServiceFaultMsg = $"Service failed to listen on {serviceUri}. \r\n\r\n{httpSysStatus} \r\n\r\nEnsure the windows HTTP service is available using 'sc config http start= demand' then 'net start http' commands."; throw; } } finally { if (serviceConfig.ConfigStatus == Shared.ConfigStatus.Updated || serviceConfig.ConfigStatus == Shared.ConfigStatus.New) { SharedUtils.ServiceConfigManager.StoreUpdatedAppServiceConfig(serviceConfig); } } }
public HttpServer(WebApp app) { _app = app; }
public UploaderResponse UploadDockets(int storeID, string password, WebApp.AdProvider.LocalDocket currentDocket) { var newResponse = new UploaderResponse(); try { Store current_store = Store.GetStore(storeID); if (current_store == null) { newResponse.is_error = true; newResponse.errorMessage = "NoStore"; } else { if (password != current_store.password) { newResponse.is_error = true; newResponse.errorMessage = "IncorrectPassword"; } else { RewardsHelper.InsertNonRewardsDocket(currentDocket, current_store, false); } } } catch (Exception ex) { newResponse.is_error = true; newResponse.errorMessage = "GenericError"; LogHelper.WriteError(ex.ToString()); } return newResponse; }