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

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.

--------------Solutions-------------

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.

Category:c# Time:2019-01-10 Views:1

Related post

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.888 (s). 13 q(s)