I wrote a method in webapi that get data by json format. This work currently but when I call this method by another parameters that length of query string is 2154 character get me error that :
The length of the query string for this request exceeds the configured maxQueryStringLength value.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The length of the query string for this request exceeds the configured maxQueryStringLength value.
I add to webconfig below code inside system.webServer
section
<security>
<requestFiltering>
<requestLimits maxQueryString="5000" maxUrl="5000" maxAllowedContentLength="102400000" />
</requestFiltering>
</security>
but don't solved.
webapi method :
[HttpPost,HttpGet]
public IHttpActionResult LockSeats(string ticketsJson, bool checkCompartment, string userId, string ipAddress)
{
try
{
List<WagonAvaliableResponse> tickets = JsonConvert.DeserializeObject<List<WagonAvaliableResponse>>(ticketsJson);
AdakTrainLibrary.ResultLockSeat resultLockSeat = _adakTrain.LockSeats(tickets, 1, 1, "1", "1", checkCompartment, userId, ipAddress, TrainUserId, TrainPass);
return Ok(resultLockSeat);
}
catch (Exception e)
{
return Ok(e);
}
}
How can i fix this?