国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

ASP.NET Core 1.0 部署 HTTPS(.NET Core 1.0)

2024-07-10 12:46:57
字體:
來源:轉載
供稿:網友

最近要做一個項目,正逢ASP.Net Core 1.0版本的正式發布。由于現代互聯網的安全要求,HTTPS加密通訊已成主流,所以就有了這個方案。
本方案啟發于一個舊版的解決方案:
ASP.NET Core 1.0 部署 HTTPS (.NET Framework 4.5.1)
http://www.cnblogs.com/qin-nz/p/aspnetcore-using-https-on-dnx451.html?utm_source=tuicool&utm_medium=referral
 在反復搜索官方文檔并反復嘗試以后得出以下解決方案
 在project.json 中,添加引用 Microsoft.AspNetCore.Server.Kestrel.Https

{ "dependencies": { //跨平臺引用 //"Microsoft.NETCore.App": { // "version": "1.0.0", // "type": "platform" //}, "Microsoft.AspNetCore.Diagnostics": "1.0.0", "Microsoft.AspNetCore.Mvc": "1.0.0", "Microsoft.AspNetCore.Razor.Tools": {  "version": "1.0.0-preview2-final",  "type": "build" }, "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", "Microsoft.AspNetCore.Server.Kestrel.Https": "1.0.0", "Microsoft.AspNetCore.StaticFiles": "1.0.0", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", "Microsoft.Extensions.Configuration.Json": "1.0.0", "Microsoft.Extensions.Logging": "1.0.0", "Microsoft.Extensions.Logging.Console": "1.0.0", "Microsoft.Extensions.Logging.Debug": "1.0.0", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0" }, "tools": { "BundlerMinifier.Core": "2.0.238", "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final", "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final" }, "frameworks": { //跨平臺引用 //"netcoreapp1.0": { // "imports": [ // "dotnet5.6", // "portable-net45+win8" // ] //} //Windows平臺通用化引用 "net452": {} }, "buildOptions": { "emitEntryPoint": true, "preserveCompilationContext": true }, "runtimeOptions": { "configProperties": {  "System.GC.Server": true } }, "publishOptions": { "include": [  "wwwroot",  "Views",  "Areas/**/Views",  "appsettings.json",  "web.config" ], "exclude": [  "wwwroot/lib" ] }, "scripts": { "prepublish": [ "bower install", "dotnet bundle" ], "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] }}

在Program.cs中,增加HTTPS訪問端口綁定

using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Threading.Tasks;using Microsoft.AspNetCore.Hosting;namespace Demo{ public class Program {  public static void Main(string[] args)  {   var host = new WebHostBuilder()    .UseKestrel()    .UseUrls("http://*", "https://*")    .UseContentRoot(Directory.GetCurrentDirectory())    .UseIISIntegration()    .UseStartup<Startup>()    .Build();   host.Run();  } }}

在 Startup.cs 文件中,啟用HTTPS訪問并配置證書路徑及密碼

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 郧西县| 固始县| 阜南县| 元江| 加查县| 娱乐| 化德县| 岑溪市| 东源县| 新乡市| 拉萨市| 江陵县| 天津市| 屏南县| 石河子市| 裕民县| 镇安县| 中宁县| 滦南县| 金堂县| 海南省| 嵊州市| 西盟| 崇州市| 昌平区| 徐闻县| 井陉县| 泗洪县| 客服| 横峰县| 临高县| 揭东县| 宜良县| 和静县| 中江县| 福贡县| 台东县| 永安市| 三原县| 嵊州市| 垦利县|