Exemple #1
0
        public async Task Can_use_with_app_base_with_web()
        {
            _webBuilder.Register("/test", async context =>
            {
                await context.Response.WriteAsync("Hello, World! " + context.Request.Path + " " + context.Request.PathBase);
            });

            using (var host = _webBuilder.BuildWebHost("", 5003))
            {
                host.Listen();
                using (var client = host.CreateClient())
                {
                    var responseMessage = await client.GetAsync("/test");

                    responseMessage.EnsureSuccessStatusCode();
                    var response = await responseMessage.Content.ReadAsStringAsync();

                    Assert.Equal("Hello, World! /test ", response);
                }
            }

            using (var host = _webBuilder.BuildWebHost("/appbase", 5003))
            {
                host.Listen();
                using (var client = host.CreateClient())
                {
                    var responseMessage = await client.GetAsync("/test");

                    responseMessage.EnsureSuccessStatusCode();
                    var response = await responseMessage.Content.ReadAsStringAsync();

                    Assert.Equal("Hello, World! /test /appbase", response);
                }
            }
        }
Exemple #2
0
 public IWebHost BuildWebHost(string appBase = null, int port = Statik.StatikDefaults.DefaultPort)
 {
     return(_webBuilder.BuildWebHost(appBase, port));
 }