I have recently converted all my apps from .NET Frameworks to .NET 6.0. I have having issue with a MVC controller method which attempts to reproduce a result that was historically created in memory, and leaves enough information for it to be re-created later. This data is not stored other than in the history of the request.
When that history is displayed, there is an option to view the result on a chart. That URL is fairly long as it includes everything needed to reproduce a graphic of the result.
Here is the HTTP error message:
HTTP Error 404.15 – Not Found
The request filtering module is configured to deny a request where the query string is too long.
Detailed Info:
Detailed Error Information:
Module RequestFilteringModule
Notification BeginRequest
Handler aspNetCore
Error Code 0x00000000
Here is a sample URL:
http://localhost:44397/Home/TradeViewer?tradeId=0&tradeDefId=32121969&accountId=1&trData=%7B%22tempGuid%22%3A%22b678a8b9-cafd-4c86-86f7-a02555e63ead%22%2C%22tradeResponse%22%3Anull%2C%22desiredUnits%22%3A1575778.0%2C%22returnOnCapital%22%3A0.0168080932588314%2C%22returnOnRisk%22%3A0.6723240020109068%2C%22TotalProfitLossEquityNet%22%3A16073.888623876659%2C%22tradeDirectionOverride%22%3Anull%2C%22equityNumberCumulativeAmount%22%3Anull%2C%22IsReversedTrade%22%3Afalse%2C%22IsAlteredTrade%22%3Atrue%2C%22reprocessedInCSharpProcessor%22%3Afalse%2C%22savedCSharpValues%22%3Anull%2C%22firstEntryBar%22%3Anull%2C%22lastCloseBar%22%3Anull%2C%22marginRequirementAtFill%22%3A46620.16259982686%2C%22marginRequirementAdditional%22%3Anull%2C%22cashValue%22%3A1165067.1608543706%2C%22TotalFinancingCharges%22%3A0.0%2C%22TotalBrokerCommissions%22%3A0.0%2C%22TradeResultId%22%3A0%2C%22AccountId%22%3A1%2C%22TradeDefinitionId%22%3A32121969%2C%22DateProcessed%22%3A%222024-09-20T11%3A24%3A28.2852507-04%3A00%22%2C%22TotalProfitLossInPips%22%3A95.800000000%2C%22TotalRiskInPips%22%3A143.700000000%2C%22TotalRewardInPips%22%3A95.800000000%2C%22FirstEntryDate%22%3A%222020-06-22T18%3A00%3A00%22%2C%22CloseDate%22%3A%222020-07-10T10%3A59%3A59.999%22%2C%22CloseReason%22%3A%22LIMIT%22%2C%22CancellationDate%22%3Anull%2C%22CancellationReason%22%3Anull%2C%22TotalProfitLossInPipsAtLimit%22%3Anull%2C%22TotalProfitLossInPipsAtMax%22%3Anull%2C%22TotalProfitLossInPipsAtMin%22%3Anull%2C%22Verified%22%3Anull%2C%22VerifiedFailedReason%22%3Anull%2C%22MustBeAuthorizedByDate%22%3Anull%2C%22DateAuthorizedByUser%22%3Anull%2C%22DateAdded%22%3A%222024-09-20T11%3A24%3A28.2852507-04%3A00%22%2C%22TotalProfitLossEquity%22%3A16073.888623876659%2C%22AccountBalanceAtEntry%22%3Anull%2C%22AccountBalanceAtExit%22%3A995250.7597023413%2C%22AccountBalanceBeforeExit%22%3A979176.8710784647%2C%22MarginRequirement%22%3A46620.65482541996%2C%22AvailableMarginAtEntry%22%3A397121.1948907204%2C%22AvailableMarginAtExit%22%3Anull%2C%22UsableAccountValue%22%3A338139.19232702616%2C%22SkippedDueToMarginRequirement%22%3Afalse%2C%22LotType%22%3A%22Unit%22%2C%22LotCount%22%3A1575778.0%2C%22Units%22%3A1575778.0%2C%22ConversionRateUnitsAtClose%22%3Anull%2C%22CopiedFromTradeResultId%22%3Anull%2C%22ApiTradeId%22%3Anull%2C%22ApiTransactionId%22%3Anull%2C%22StopLossPriceOverride%22%3Anull%2C%22ExceptionDetails%22%3Anull%2C%22FirstEntryPrice%22%3A0.70054%2C%22LastClosePrice%22%3A0.69096%2C%22ConversionRateUnitsAtEntry%22%3Anull%2C%22ConversionRateMarginAtEntry%22%3Anull%2C%22ApiStopLossOrderId%22%3Anull%2C%22ApiTakeTrailingStopLossOrderId%22%3Anull%2C%22ApiTakeProfitOrderId%22%3Anull%2C%22CommissionAtEntry%22%3Anull%2C%22FinancingAtEntry%22%3Anull%2C%22GuaranteedExecutionFeeAtEntry%22%3Anull%2C%22HalfSpreadCostAtEntry%22%3Anull%2C%22CommissionAtExit%22%3Anull%2C%22FinancingAtExit%22%3Anull%2C%22GuaranteedExecutionFeeAtExit%22%3Anull%2C%22HalfSpreadCostAtExit%22%3Anull%2C%22DirectionalBiasRuntimeDataId%22%3Anull%2C%22DirectionalBiasBetAlgorithmIndex%22%3A301%2C%22DirectionalBiasValue%22%3A%22Bearish%22%2C%22TrailingStopActivationPrice%22%3Anull%2C%22TrailingStopTrailingAmountInDecimal%22%3Anull%2C%22TrailingStopIgnoreLimit%22%3Anull%2C%22UpdatedPriceStopLoss%22%3Anull%2C%22UpdatedPriceTakeProfit%22%3Anull%2C%22UpdatedPriceTrailingStopLoss%22%3Anull%2C%22UpdatedByAccountUpdate%22%3Anull%2C%22AccountTradeSettingId%22%3A0%2C%22ActionOverride%22%3Anull%2C%22StopOverride%22%3A0.71491%2C%22LimitOverride%22%3A0.69096%2C%22CloseByDate%22%3A%222020-09-21T17%3A00%3A00%22%2C%22EnterByDate%22%3A%222020-06-25T05%3A00%3A00%22%2C%22TotalRiskEquity%22%3A23907.95%2C%22FinancingOnTrade%22%3Anull%2C%22AccountBalanceAtCreate%22%3A956318.386407752%2C%22UnrealizedProfitLoss%22%3Anull%2C%22LastUpdateDate%22%3Anull%2C%22Account%22%3Anull%2C%22Positions%22%3A%5B%5D%2C%22TradeDefinition%22%3Anull%2C%22AccountTradeSetting%22%3Anull%7D
I have spent nearly a full day searching for an answer, and many answers say to change the web.config. I did that (for IIS Express) and that does NOT change the result.
I have also seen answers which indicate to use the [RequestSizeLimit(16384)] attribute on the Controller Method. That also does not change the result.
I have also seen some answers on how to configure the length for Kestrel, but I am not using Kestrel. I tried this (even though not using Kestrel) and of course it also did not work.
Does anyone know how to configure the length of the query string, on ASP.NET Core MVC?
Does anyone know how to disable or configure the ‘RequestFilteringModule’ ?
I tried changing the web.config
for IIS Express.
I tried adding the Request Size Limit attribute to the controller method.
I tried configuring Kestrel in the app startup.
None of these changed the result.
So… I was asked to provides steps to reproduce this issue. Here are those steps:
-
Create a new Project and select the ASP.NET Core MVC project template
-
Open the index view
Views/Index.cshtml
. Add a link<a hRef = "very long URI">Very Long Query String</a>
-
Change the configuration to ‘IIS Express’ and run the app.
-
Click the link added to Index. The error will appear.
Now, while I was reproducing this issue, I found the there was not issue unless I used the ‘IIS Express’ configuration. If I used the configuration named after the created project, then I DID NOT GET the error. This was an obvious clue that the issue was in IIS and not in the code/project per say.
From this observation, I found the solution. I added the following to the applicationhost.config file [located in $SOLUTION_FOLDER/.vs/$PROJECT_NAME/config/applicationhost.config].
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="524288000" maxQueryString="16384" />
</requestFiltering>
</security>
</system.webServer>
The key change here is the maxQueryString value. I changed this value to 16K and the issue was resolved.
jpl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2