-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Returning a RedirectResult with a URL causes NullReferenceException #3986
Comments
Getting the same here as well after the 2.16 update possibly. |
We have a similar issue when returning a |
yep, also are running into this problem. |
it looks like Type UrlHelperBase in Microsoft.AspNetCore.Mvc.Core, This ActionContext instance is passed within the call-stack, but is created within method: For me adjusting the Function Runtime version is disturbing for our CI process. public override Task ExecuteResultAsync(ActionContext context)
{
....
if (context.RouteData == null)
context.RouteData = new RouteData();
return base.ExecuteResultAsync(context);
} |
@tjgalama Indeed, we noticed that that was the origin of the exception aswell. We created a workaround by creating a derived type of StatusCodeResult and generating a Redirect there. But your workaround is cleaner IMO. Well it works, so we'll leave it as is. |
Closed by accident |
cc @pranavkm |
Investigative information
Please provide the following:
Repro steps
Expected behavior
Receive an HTTP redirect.
(it still works like this on version 2.0.12246.0)
Actual behavior
Receive an HTTP InternalServerError caused by a NullReferenceException in the UrlHelperBase.
(issue on 2.0.12275.0)
Known workarounds
Return a custom ActionResult like this:
Related information
Exception details:
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Microsoft.AspNetCore.Mvc.Core
StackTrace:
at Microsoft.AspNetCore.Mvc.Routing.UrlHelperBase..ctor(ActionContext actionContext) in //src/Microsoft.AspNetCore.Mvc.Core/Routing/UrlHelperBase.cs:line 31
at Microsoft.AspNetCore.Mvc.Routing.UrlHelperFactory.GetUrlHelper(ActionContext context) in //src/Microsoft.AspNetCore.Mvc.Core/Routing/UrlHelperFactory.cs:line 64
at Microsoft.AspNetCore.Mvc.Infrastructure.RedirectResultExecutor.ExecuteAsync(ActionContext context, RedirectResult result) in //src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/RedirectResultExecutor.cs:line 48
at Microsoft.AspNetCore.Mvc.RedirectResult.ExecuteResultAsync(ActionContext context) in //src/Microsoft.AspNetCore.Mvc.Core/RedirectResult.cs:line 110
at Microsoft.Azure.WebJobs.Script.WebHost.Middleware.FunctionInvocationMiddleware.d__2.MoveNext() in C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\Middleware\FunctionInvocationMiddleware.cs:line 70
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in E:\A_work\243\s\src\mscorlib\src\System\Runtime\ExceptionServices\ExceptionDispatchInfo.cs:line 132
The text was updated successfully, but these errors were encountered: