1.安裝 aspnetcore-runtime-3.1.1-win-x64.exe
2.安裝dotnet-hosting-3.1.1-win.exe
3.安裝urlrewrite和application request routing
1.安裝 aspnetcore-runtime-3.1.1-win-x64.exe
下載地址:https://dotnet.microsoft.com/download/dotnet-core/3.1
我這里是64位
2.安裝dotnet-hosting-3.1.1-win.exe
下載地址:https://dotnet.microsoft.com/download/dotnet-core/3.1
3.安裝urlrewrite和application request routing
urlwrite地址:https://www.iis.net/downloads/microsoft/url-rewrite
application request routing地址:https://www.iis.net/downloads/microsoft/application-request-routing
這倆項並非必須安裝的,只是自己在踩坑的過程中查找需要安裝配置,但好像沒有影響到部署,先記錄下來
這里netcore主要是采用了Microsoft.AspNetCore.Cors實現跨域的,讀取配置文件的IP
public static class CorsSetup { public static void AddCorsSetup(this IServiceCollection services) { if (services == null) throw new ArgumentNullException(nameof(services)); services.AddCors(c => { c.AddPolicy("LimitRequests", policy => { // 支持多個域名端口,注意端口號后不要帶/斜桿:比如localhost:8000/,是錯的 // 注意,http://127.0.0.1:1818 和 http://localhost:1818 是不一樣的,盡量寫兩個 policy .WithOrigins(Appsettings.app(new string[] { "Startup", "Cors", "IPs" }).Split(',')) .AllowAnyHeader()//Ensures that the policy allows any header. .AllowAnyMethod(); }); }); } } //在Startup下的ConfigureServices函數中注冊 services.AddCorsSetup(); //在Startup下的Configure函數中配置 app.UseCors("LimitRequests");
這是我Vue前端自己的配置文件,修改自己的請求地址
Vue配置代理路徑
IIS沒有太多需要注意的地址,試了幾次就是不能分配固定IP