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.

-------------Problems Reply------------

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# Views:27 Time:2019-01-01

Related post

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

processed in 0.175 (s). 11 q(s)