Redirect to ActionResult Method in the same controller - Authorization header is missing - ERROR

773 views Asked by At

I am trying to redirect from a controller action (using RedirectToAction()) to another action in the same controller.

The website is using @Html.AntiForgeryToken(), and I get the error in the request:

Authorization header is missing

I haven't set [ValidateAntiForgeryToken] on that method, and don't really need forgery checking for this one.

Does anyone know how should I proceed?

The actual behavior is that from a method, I redirect to another which is trying to download an excel file.

Thanks.

1

There are 1 answers

0
Ondrej Svejdar On

Why are you using redirect ? If you just want the output of another method, you can simple call

ActionResult MyOriginalMethod()
{
  ...
  return AnotherControllerMethod(parameter);
  ...
}

instead of

ActionResult MyOriginalMethod()
{
  ...
  return RedirectToAction("AnotherControllerMethod");
  ...
}

the later actually performs http redirect, which is a) slower b) you have to set context properly.