网络通讯
unity的请求类 UnityWebRequest
静态类创建(UnityWebRequest.Get())的Request是自带DownloadHandler和UploadHandler的
而构造创建(new UnityWebRequest() )是没有的,需要自己手动创建赋值,否则无法正常上传与接收数据
异常情况
.net实现服务器用于上传文件时,返回413错误提示上传文件过大
上传文件较大时,接收方需要做以下操作

public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
services.Configure<FormOptions>(x =>
{
x.ValueLengthLimit = 2147483647;
x.MultipartBodyLengthLimit = 2147483647; //2G
});
}
如果接收方使用的是iis则还需要做一下设置:
-
打开IIS,找到文件上传的项目,选中->功能试图->配置编辑器

-
修改两处(httpRuntime、requestLimits )
-
system.web/httpRuntime中executionTimeout与maxRequestLength

-
system.webServer/security/requestFiltering中requestLimits的maxAllowedContentLength

-