Я работаю в. NET ядро 2.2 приложения. При вызове API я получил ошибку HTTP 404.15.
Поскольку я не передаю большое количество элементов в URL.
И у меня нет привилегий изменять IIS, как указано ниже.
<configuration>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxQueryString="3000" maxUrl="1000" /> /* Change the Url limit here */
</requestFiltering>
</security>
</system.webServer>
</configuration>
Я также попробовал следующие решения, но они не работают.
[HttpPost]
[RequestSizeLimit(40000000)]
public async Task<IActionResult> UploadFiles(IFormFile file)
{
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseKestrel(options =>
{
options.Limits.MaxRequestBodySize = 52428800; //50MB
});
}
app.UseWhen(context => context.Request.Path.StartsWithSegments("/api"), appBuilder =>
{
context.Features.Get<IHttpMaxRequestBodySizeFeature>().MaxRequestBodySize = null;
//TODO: take next steps
});
Это мой вызов API
https://localhost:44473/ControllerName/InsertProduct?ProductSubCategoryId="4"&ProductName="Canon EOS 200D II DSLR Camera EF-S 18 - 55 mm IS STM and 55 - 250 mm IS STM (Black)"&ProductDescription="Is photography one of your passions? Bring home this EOS 200D II from Canon. This is Canon’s lightest DSLR that features a vari-angle LCD touch screen. It features a 24.1-megapixels APS-C CMOS sensor and a DIGIC 8 processor that capture stunning images. The EOS 200D II also has a lot of other features that make everyday photography a lot easier."&ProductSpecification="{"Specification":[{"In The Box": "1 Camera Body, 18 - 55 mm Lens, 55 - 250 mm Lens, Battery, Battery Charger, USB Cable, Camera Bag"},{"Model Number": "EOS 200D II"},{"Model Name": "eos200dii"},{"SLR Variant": "EF-S 18 - 55 mm IS STM and 55 - 250 mm IS STM"},{"Effective Pixels": "24.1 MP"},{"Image Sensor Size": "22.3 x 14.9"},{"Sensor Type": "CMOS"},{"Lens Mount": "EF Mount"},{"Shutter Speed": "1/4000 - 30 sec"},{"Image Format": "JPEG, RAW, C-RAW, RAW + JPEG, C-RAW + JPEG"},{"Video Resolution": "1920 x 1080"},{"Video Quality": "Full HD"},{"Battery Type": "Lithium"},{"Weight": "654g"}]}"&ProductOptions="{"Options":[{"Bank Offer":"10% Instant discount with HDFC Bank PayZapp Card on purchase of Rs.300 or more"},{"No Cost EMI": "Avail No Cost EMI on select cards for orders above ?3000"},{"Partner Offers":"Get FLAT 5% BACK with Amazon Pay ICICI Bank Credit card card for Prime members. Flat 3% BACK for non-Prime members. No minimum order value. No upper limit on cashback."}]}"&ProductPrice="57499"&ProductBrand="Canon"&IsActive="True"&Quantity="50"&ImageURL="NULL"
Метод вызова в контроллере
public int InsertProduct(Product product)
{
Dictionary<string, object> keyValues = this.GetProperty<Product>(product);
int i = bl.AddProduct<Product>(keyValues);
return i;
}
Так что любой может предложить мне лучшую идею для решения этой проблемы.