I found out what caused the issue. The problem is that the endpoint uses TempData
, and the value was too large. It did not cause the application to throw an exception, but instead, it set HttpContext.RequestAborted.IsCancellationRequested
to true. It is strange because when we use TempData.Put
, it will not throw an exception, but if we use TempData[key]
, it will throw an exception if the value is too large. So better use TempData[key]
.
Why my ASP.NET razor page app cannot access a specific endpoint?
I have an issue with my ASP.NET app where it cannot access a specific endpoint. It throws a 502 error in Azure and a request timed out on my local machine. The endpoint I want to access is the products endpoint. I found that HttpContext.RequestAborted.IsCancellationRequested
is set to true after passing through a certain middleware, which I can't identify since it is a built-in middleware and I cannot put a breakpoint on it. I noticed this because I have a custom middleware, and before calling the await _next(httpContext);
method, IsCancellationRequested
is set to false. However, after it is called, IsCancellationRequested
is set to true, which I believe is the main reason for the error. Additionally, I discovered that I can access the products endpoint in incognito mode because IsCancellationRequested
is always false whether before or after calling await _next(httpContext);
, which is quite strange.
2 answers
Sort by: Most helpful
-
Alex Corsega 5 Reputation points
2024-07-24T22:04:23.6366667+00:00 -
Bruce (SqlWork.com) 66,461 Reputation points
2024-07-23T18:49:48.0633333+00:00 most likely the request is timing out. the timeout is what sets the cancellation token.