标签: kestrel-http-server

ASP.NET 5将应用程序添加为IIS应用程序

我正在将一些应用程序从ASP.NET 5 beta7迁移到RC1.使用HTTPPlatformHandler我可以运行任何这些ASP.NET 5 RC1应用程序作为IIS站点的根目录.但它们不会作为网站的子目录(右键单击"添加应用程序")运行.完整的回复显示:

HTTP/1.1 404 Not Found
Content-Length: 0
Server: Kestrel
X-Powered-By: ASP.NET
Date: Tue, 24 Nov 2015 14:59:04 GMT
Run Code Online (Sandbox Code Playgroud)

这不是权限问题,因为当应用程序是站点的根目录并使用相同的应用程序池时,路由会成功提供.

应用程序池配置为"无托管代码"和集成管道.

root应用程序的web.config如下所示:

<configuration>
  <system.webServer>
    <handlers>
      <add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
    </handlers>
    <httpPlatform processPath="..\approot\web.cmd" arguments="" stdoutLogEnabled="false" stdoutLogFile="..\logs\stdout.log" startupTimeLimit="3600"></httpPlatform>
  </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

对于子应用程序,我必须删除httpplatformhandler处理程序以避免错误"无法添加类型为'add'的重复集合条目,并将唯一键属性'name'设置为'httpplatformhandler'".

现在我们必须使用kestrel/httpplatformhandler,是否可以在站点下作为应用程序运行?

iis-7.5 kestrel-http-server asp.net-core

4
推荐指数
1
解决办法
1540
查看次数

如何为Kestrel响应添加no-cache?

我使用Asp.Net Core RC2和Kestrel作为我的Web服务器.我需要确保使用no-cache标头响应请求(在这种情况下所有这些请求),以便浏览器获得最新版本(而不是304).

在Startup中有没有办法配置Kestrel或将此步骤注入管道?

编辑:在我的情况下,no-store可能是更好的选择:https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching "no-store不允许缓存响应并且必须在每次请求时全部取出."

asp.net kestrel-http-server asp.net-core

4
推荐指数
1
解决办法
1621
查看次数

使用 Kestrel 和 .NET 核心中间件压缩 HTTP 响应

我希望使用 .NET Core 和 Kestrel Web 服务器动态编码 HTTP 响应。以下代码不起作用,响应无法在浏览器中加载。

        var response = context.Response;


        if (encodingsAccepted.ToArray().Any(x => x.Contains("gzip")))
        {
            // Set Gzip stream.
            context.Response.Headers.Add("Content-Encoding", "gzip");
            // Wrap response body in Gzip stream.
            var body = context.Response.Body;


            context.Response.Body = new GZipStream(body, CompressionMode.Compress);


        }
Run Code Online (Sandbox Code Playgroud)

.net middleware asp.net-core-mvc kestrel-http-server

4
推荐指数
2
解决办法
3277
查看次数

输入字符串包含非ASCII或空字符

2016-12-02 02:54:39:180 [WARNING] Microsoft.AspNetCore.Server.Kestrel -    Connection processing ended abnormally
Microsoft.AspNetCore.Server.Kestrel.BadHttpRequestException: The input string contains non-ASCII or null characters.
at Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure.MemoryPoolIteratorExtensions.GetAsciiString(MemoryPoolIterator start, MemoryPoolIterator end)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Frame.TakeStartLine(SocketInput input)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Frame`1.<RequestProcessingAsync>d__2.MoveNext()
2016-12-02 09:17:10:819 [ERROR] Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware - An unhandled exception has occurred: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at Gillie.JobCenter.Controllers.WebApi.QuestionnairesController.<SaveConsultant>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) …
Run Code Online (Sandbox Code Playgroud)

c# ascii nullreferenceexception kestrel kestrel-http-server

4
推荐指数
1
解决办法
669
查看次数

如何直接在Kestrel中使用PEM证书?

我想在我的ASP.Net Core 2.0(带有Kestrel Web服务器)应用程序中使用HTTPS。

官方文档使用pfx格式,但是我想直接使用PEM格式(由Let's crypto生成),而无需进行任何转换(至少在我的C#代码之外没有任何转换)。有可能吗?

c# ssl-certificate .net-core kestrel-http-server asp.net-core

4
推荐指数
3
解决办法
3050
查看次数

ASP.NET Core包含所有日志条目中的时间戳

我有一个ASP.NET Core 2.0应用程序,启用了内置控制台日志记录.这是WebHost的创建:

var webHost = WebHost.CreateDefaultBuilder(args)
            .UseUrls("http://localhost:5002")
            .UseStartup<Startup>()
            .UseApplicationInsights()
            .Build();

webHost.Run();
Run Code Online (Sandbox Code Playgroud)

发送HTTP POST请求时,将生成以下日志消息并显示在Console stdout中:

info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
  Request starting HTTP/1.1 POST http://localhost:5002/api/sample application/json 2144
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
  Executing action method MyApp.Controllers.SampleController.Post (Model.Solve) with arguments (MyApp.Request.MyRequest) - ModelState is Valid
info: Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutor[1]
  Executing ObjectResult, writing value Microsoft.AspNetCore.Mvc.ControllerContext.
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
  Executed action MyApp.Controllers.SampleController.Post (MyApp) in 1201.9411ms
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
  Request finished in 1446.1907ms 200 application/json; charset=utf-8
Run Code Online (Sandbox Code Playgroud)

作为进入生产的一个要求,我需要所有日志条目都包含一个时间戳:现在,我知道我可以在调用Log()方法时自己提供时间戳,如GitHub ASP.NET Logging存储库中的这个开放性问题所述,但是我应该如何直接在WebHost生成的日志消息上这样做(如上所示)?有没有办法添加时间戳,而不必像在StackOverflow答案中提出的解决方案那样重写完整的自定义Logger ?

谢谢.

c# logging .net-core kestrel-http-server asp.net-core

4
推荐指数
2
解决办法
2457
查看次数

无法找到Kestrel使用的自签名可信证书

我有一个非常基本的自托管.NET核心2.1应用程序,具有以下配置:

public class Program
{
    public static void Main(string[] args)
    {
        var host = new WebHostBuilder()
             .UseKestrel()
             .UseContentRoot(Directory.GetCurrentDirectory())
             .UseStartup<Startup>()
             .Build();

        host.Run();
    }
}
Run Code Online (Sandbox Code Playgroud)

和非常典型的简单控制器如下:

   [Route("api/[controller]")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        // GET api/values
        [HttpGet]
        public ActionResult<IEnumerable<string>> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/values/5
        [HttpGet("{id}")]
        public ActionResult<string> Get(int id)
        {
            return "value";
        }

        // POST api/values
        [HttpPost]
        public void Post([FromBody] string value)
        {
        }

        // PUT api/values/5
        [HttpPut("{id}")]
        public void Put(int id, [FromBody] …
Run Code Online (Sandbox Code Playgroud)

https kestrel-http-server asp.net-core asp.net-core-webapi asp.net-core-2.0

4
推荐指数
1
解决办法
5647
查看次数

Problems running/configure self hosted console application (ASP.net core 2.1, Kestrel) with public certificate on a windows webserver

I have developed various webservices in the past (VB ASP.net web-api applications) with https for production. I have done the development with http and then setup https on the production servers. To setup a port on the production server for https and the certificate, I have:

  1. Imported a public certificate in the certificate store on the windows server configured a specific port for https with netsh. E.g:

netsh http add urlacl url=https://+:22224/ user=everyone

  1. bound the certificate (over the thumbprint) …

https certificate asp.net-core-mvc kestrel-http-server asp.net-core-2.1

4
推荐指数
2
解决办法
1万
查看次数

HTTP 动词 PUT 和 DELETE:405 方法不允许 - 如何允许?

我一直在尝试 ASP.NET 的所有建议解决方法,以便能够通过 HTTP 方法 PUT 和 DELETE 解决我的 REST Web 服务。但是,它们似乎都不起作用。(即删除 WebDAV 处理程序或允许所有动词到 ExtensionlessHandler)。

ASP.NET Core Web API(在 IIS 上)需要什么来允许这两个动词(HTTP PUT 和 DELETE)?

PS:我已经使用 CORS 配置了我们的 Web API 项目,但我正在从同一来源的网页访问 Web 服务。所以这也不是 CORS 问题。

iis rest kestrel-http-server asp.net-core

4
推荐指数
2
解决办法
1万
查看次数

在 netcore 控制台应用程序中使用 Web 服务器进行简单路由

我无法让路由与 kestrel 一起工作。

我找不到关于如何在 netcore 控制台应用程序中实现这一点的任何好的教程。

我想构建一个简单的 Web 服务器,它将有 2-3 个我可以访问的端点。

public class WebServer
{
    public static void Init()
    {
        IWebHostBuilder builder = CreateWebHostBuilder(null);
        IWebHost host = builder.Build();
        host.Run();
    }

    public static IWebHostBuilder CreateWebHostBuilder(string[] args)
    {
        var config = new ConfigurationBuilder()
        .SetBasePath(Directory.GetCurrentDirectory())
        .Build();

        return WebHost.CreateDefaultBuilder(args)
            .UseUrls("http://*:5000")
            .UseConfiguration(config)
            .UseStartup<Startup>();
    }

    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddRouting();
            // ????
        }

        public void Configure(IApplicationBuilder app)
        {
            // ????
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c# kestrel-http-server asp.net-core

4
推荐指数
1
解决办法
3953
查看次数