asp.net-core - ASP.NET Core:重定向问题
问题描述
我有从 http 重定向到 https 的问题:
http:*** => https:***:44345 是否可以不在 url 中显示端口 44345?
我的项目配置:
启动设置.json:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:57854",
"sslPort": 44345
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Site": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
启动.cs:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseHsts();
app.UseFileServer();
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapRazorPages();
});
}
请指教
解决方案
只有 http 和 https 的端口 80 和 443 分别允许在地址中省略端口。这是因为您的浏览器会看到 http 或 https 并透明地向适合该协议的端口发出请求。
推荐阅读
- java - 从 Firebase 身份验证中获得更多时间短信验证
- r - calculate_centralities(net, include = "Information Centrality") 中的错误:输入不是 igraph 对象或可能未连接
- javascript - 我尝试使用 fisher-yates shuffle 字符串,但没有奏效
- python - 用户提供的 MSSQL 数据库的 Pivotal/Django 设置
- ios - UICollection 视图的无限滚动
- c# - 单击该项目中的按钮时,如何访问 ListviewItem 的数据?
- ionic-framework - Ionic 4 组件未在导航上呈现
- jquery - 将具有相同类名的 div 附加到具有相同 id 名称的 div 中
- nix - Nix派生捆绑多个程序
- sql-server - 使用递增值更新组