NetCore发布后修改端口和localhost改IP局域网访问+文件上传大小设置
1、改端口:在program中
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseKestrel(o => {
o.Listen(IPAddress.Loopback, 9998);
o.Limits.MaxRequestBodySize = null;
}).UseUrls("http://*:9998", "http://localhost:9998");
webBuilder.UseStartup<Startup>();
});
2、改ip:在appsettings.json:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://*:9998"
}
}
}
}
3、文件大小设置为最大startup中:
services.Configure<FormOptions>(x =>
{
x.ValueLengthLimit = int.MaxValue;
x.MultipartBodyLengthLimit = int.MaxValue;
x.MultipartHeadersLengthLimit = int.MaxValue;
});
services.AddMvc();
4、启动exe文件:
浙公网安备 33010602011771号