Example #1
0
        private static void Main(string[] args)
        {
            const string url = "http://localhost:4545";

            var exitEvent = new ManualResetEvent(false);

            // Hook up the Ctrl+C to exit the application
            System.Console.CancelKeyPress += (sender, eventArgs) =>
            {
                eventArgs.Cancel = true;
                exitEvent.Set();
            };

            // Get NanoConfiguration used by the demo projects. Replace this with your own code.
            var config = NanoConfigurationHelper.GetNanoConfiguration();

            // Specify your application name. A reasonable default is automatically used if not
            // supplied but it's definitely recommended to supply one.
            config.ApplicationName = "Nano.Demo.SelfHost.Console";

            using (var server = HttpListenerNanoServer.Start(config, url))
            {
                if (Debugger.IsAttached)
                {
                    Process.Start(url + "/ApiExplorer/");
                }

                System.Console.WriteLine("Nano Server is running on: " + url);
                System.Console.WriteLine("Press Ctrl+C to exit.");
                System.Console.WriteLine(config.ToString());
                exitEvent.WaitOne();
            }
        }
Example #2
0
            public void Start(string urls)
            {
                var validatedUrls = ValidateUrls(urls);

                // Get NanoConfiguration used by the demo projects. Replace this with your own code.
                var config = NanoConfigurationHelper.GetNanoConfiguration();

                // Specify your application name. A reasonable default is automatically used if not
                // supplied but it's definitely recommended to supply one.
                config.ApplicationName = "Nano.Demo.SelfHost.Topshelf";

                // Start the server passing in the NanoConfiguration and a list of URLs to listen on.
                _server = HttpListenerNanoServer.Start(config, validatedUrls);

                // Optionally specify a virtual application path if your application URL is going to use one.
                // Example: http://localhost:4545/ExecutiveDashboard/
                _server.HttpListenerConfiguration.ApplicationPath = "";

                string url = _server.HttpListenerConfiguration.GetFirstUrlBeingListenedOn();

                // If the debugger is attached go ahead and launch a browser window directly to the Api Explorer page.
                if (Debugger.IsAttached)
                {
                    Process.Start(url + "ApiExplorer");
                }

                Console.WriteLine("Nano Server is running on: " + url);
                Console.WriteLine(config.ToString());
            }
Example #3
0
        public static void StartupNano(HttpApplication httpApplication)
        {
            // Get NanoConfiguration used by the demo projects. Replace this with your own code.
            var config = NanoConfigurationHelper.GetNanoConfiguration();

            config.RequestHandlers.Remove(config.RequestHandlers.First(handler => handler.UrlPath == "/"));
            config.AddDirectory("/", "www", returnHttp404WhenFileWasNotFound: false);

            // Specify your application name. A reasonable default is automatically used if not
            // supplied but it's definitely recommended to supply one.
            config.ApplicationName = "Nano.Demo.AspNet";

            SystemWebNanoServer.Start(httpApplication, config);
        }
Example #4
0
            public static void Start(string url, string applicationName)
            {
                // Get NanoConfiguration used by the demo projects. Replace this with your own code.
                var config = NanoConfigurationHelper.GetNanoConfiguration();

                // Specify your application name. A reasonable default is automatically used if not
                // supplied but it's definitely recommended to supply one.
                config.ApplicationName = "Nano.Demo.SelfHost.WindowsService";

                _server = HttpListenerNanoServer.Start(config, url);

                url = _server.HttpListenerConfiguration.GetFirstUrlBeingListenedOn();

                if (Debugger.IsAttached)
                {
                    Process.Start(url + "ApiExplorer/");
                }

                Console.WriteLine("Nano Server is running on: " + url);
            }