I have an ASP.NET Core 2 web app. It's actually an implementation of Identity Server 4, but I don't believe that is related to my issue. I have a controller with an action that represents the callback from an external OAuth service. I've stripped out all the handler logic, leaving just this:
[HttpGet]
[AllowAnonymous]
[Route("challenge/callback")]
public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null, string remoteError = null)
{
TempData["Test"] = "hello world";
return RedirectToAction("Index", "App", new { path = "oauth-register" });
}
You can see I'm setting some tempt data and redirecting. The view it redirects to simply iterates the TempData
collection and renders each key/value.
The application is using a default implementation of TempData
, so no extra providers registered or anything.
I now perform the following 2 actions:
- I visit this challenge/callback URL in my browser and confirm I'm redirected as expected and my temp data "hello world" is written to the screen.
- I now follow my application's sign in path, get redirected to the external provider, sign in and get redirected back to my application. Here the debugger passes through the above action and again performs the same redirect. But this time the
TempData
collection is empty and nothing is written out by the target view.
I cannot understand this because surely as far as my application is concerned both these actions are identical. They are both GET requests for the same endpoint. Does TempData
behave different based on referer or other request-specific variable?
I hope someone can put me out of my misery here!