在asp.net-core项目中启用httpsssl时,我是否需要设置重定向到SSL连接?

2026-03-30 12:171阅读0评论SEO教程
  • 内容介绍
  • 相关推荐

本文共计195个文字,预计阅读时间需要1分钟。

在asp.net-core项目中启用https/ssl时,我是否需要设置重定向到SSL连接?

我在dotnet核心创建了网站。该网站现场直播,并在Azure中托管。我已经设置了SSL证书并将其绑定到该站点。在web.config或启动中,我有什么方法可以让SSL工作?我无法使用HTTPS看到该网站。

我现在在dotnet核心创建了一个网站.该网站现场直播,并在azure中托管.我已经设置了ssl sertificate,并将其绑定到该站点.

在web.config或启动中我有什么办法让ssl工作吗?

我无法使用" + context.Request.Host + context.Request.Path; context.Response.Redirect(withHttps); } }); 在启动时,您可以将整个站点配置为要求https,如下所示:

编辑:显示如何在生产中仅需要https但请注意,您可以轻松地在开发中使用https

在asp.net-core项目中启用https/ssl时,我是否需要设置重定向到SSL连接?

public Startup(IHostingEnvironment env) { ... environment = env; } public IHostingEnvironment environment { get; set; } public void ConfigureServices(IServiceCollection services) { ... services.Configure<MvcOptions>(options => { if(environment.IsProduction()) { options.Filters.Add(new RequireHttpsAttribute()); } }); }

本文共计195个文字,预计阅读时间需要1分钟。

在asp.net-core项目中启用https/ssl时,我是否需要设置重定向到SSL连接?

我在dotnet核心创建了网站。该网站现场直播,并在Azure中托管。我已经设置了SSL证书并将其绑定到该站点。在web.config或启动中,我有什么方法可以让SSL工作?我无法使用HTTPS看到该网站。

我现在在dotnet核心创建了一个网站.该网站现场直播,并在azure中托管.我已经设置了ssl sertificate,并将其绑定到该站点.

在web.config或启动中我有什么办法让ssl工作吗?

我无法使用" + context.Request.Host + context.Request.Path; context.Response.Redirect(withHttps); } }); 在启动时,您可以将整个站点配置为要求https,如下所示:

编辑:显示如何在生产中仅需要https但请注意,您可以轻松地在开发中使用https

在asp.net-core项目中启用https/ssl时,我是否需要设置重定向到SSL连接?

public Startup(IHostingEnvironment env) { ... environment = env; } public IHostingEnvironment environment { get; set; } public void ConfigureServices(IServiceCollection services) { ... services.Configure<MvcOptions>(options => { if(environment.IsProduction()) { options.Filters.Add(new RequireHttpsAttribute()); } }); }