So, I've got an Admin Controller that uses the [Authorize] notation with a single admin account (for content management purposes). If the administrator is not logged on, it redirects the user to the login view.
In the Admin controller, I've this ActionResult:
public ActionResult GeneratePDF(int? id) {
return new ActionAsPdf("PrintOrder/" + id) {
FileName = Server.MapPath("~/PDF/test.pdf")
};
}
The above code is currently for testing purposes and will be modified later.
However, when I call the ActionResult from a View (beeing logged on as admin), it only generates a PDF of the Login View as if there is no valid admin session and the user gets redirected. The code works when using the [AllowAnonymous] notation on the PrintOrder ActionResult, but not when a valid user session is required.
Any ideas on how to let the ActionAsPdf method access the required PrintOrder method and still be secured by the [Authorize] notation?
I'm calling the Action from a View as follows:
<a href="@Url.Action("GeneratePDF", "Admin", new { id = item.ID })">Get PDF</a>