ASP.NET Core 2.1 + Kestrel(如何禁用HTTPS)

编程入门 行业动态 更新时间:2024-10-12 16:21:41
本文介绍了ASP.NET Core 2.1 + Kestrel(如何禁用HTTPS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

因此,随着ASP.NET Core 2.1的出现,Kestrel现在自动在HTTP旁边创建一个HTTPS终结点,并且默认项目模板已设置为从HTTP重定向到HTTPS(很容易撤消).

So it appears with the advent of ASP.NET Core 2.1, Kestrel now automatically creates an HTTPS endpoint along side the HTTP one, and default project templates are setup to redirect from HTTP to HTTPS (which is easy enough to undo).

但是我的问题是...如何为我的项目完全禁用HTTPS.我已经阅读了文档,并使用了HTTPS的各种配置设置,但似乎没有什么允许我关闭它并仅运行HTTP项目.

However my question is... how can I disable HTTPS entirely for my project. I've read through the docs and played with a variety of config settings for HTTPS but nothing I do seems to allow me to turn it off and just run an HTTP project.

我疯了还是只想念点东西.我希望这非常容易做到.

Am I crazy or just missing something. I would expect this to be super easy to do.

推荐答案

找出实现我想要做的正确方法,就是使用.UseKestrel()专门配置Kestrel并简单地指定一个地址,如下所示:

Turns out the proper way to achieve what I wanted to do, was to specifically configure Kestrel with .UseKestrel() and simply specify a single address, like this:

WebHost.CreateDefaultBuilder(args) .UseKestrel(options => { options.Listen(IPAddress.Loopback, 5080); //HTTP port }) .UseStartup<Startup>();

影响覆盖默认设置,并在Kestel启动时显示此警告:

in affect overriding the default setup, and displaying this warning when Kestel starts:

warn: Microsoft.AspNetCore.Server.Kestrel[0] Overriding address(es) 'localhost:5001, localhost:5000'. Binding to endpoints defined in UseKestrel() instead.

如果指定了第二个地址,则将假定该地址将使用内置的开发者证书进行保护,例如:

if a second address is specified it will assume that address is to be secured with the built-in developer cert, as such:

WebHost.CreateDefaultBuilder(args) .UseKestrel(options => { options.Listen(IPAddress.Loopback, 5080); //HTTP port options.Listen(IPAddress.Loopback, 5443); //HTTPS port }) .UseStartup<Startup>();

您当然可以按照以下说明专门保护您的SSL地址:

you may of course specifically secure your SSL address as described here:

> https ://docs.microsoft/zh-cn/aspnet/core/fundamentals/servers/kestrel?view = aspnetcore-2.1& tabs = aspnetcore2x

这是生产设置所必需的.

which is necessary for production setups.

更多推荐

ASP.NET Core 2.1 + Kestrel(如何禁用HTTPS)

本文发布于:2023-11-14 04:07:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1586170.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Core   NET   ASP   HTTPS   Kestrel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!