Add a header parameter in refresh action

Dec 19, 2016 at 7:03 PM
Edited Dec 19, 2016 at 7:15 PM
Morning.

I have a situation here.
I'm using MVC5 and everything works fine with Captcha MVC, until now.

I'm using a custom AntiForgeryToken (for security reasons), and every "POST" need to send a new header called "__myCustomFT", with some value.

The problem is: the "Refresh" button of Captcha MVC do a "POST" with this:
captchaManager.RefreshUrlFactory = (helper, pair) =>
            {
                var dictionary = new RouteValueDictionary();
                dictionary.Add(MultipleParameterKey, i);
                return helper.Action("Refresh", "DefaultCaptcha", dictionary);
            };
The problem is: this POST need to have my new Header key, but I don't know where to put this. I tried:
helper.RequestContext.HttpContext.Request.Headers.Add("__myCustomFT", "some value");
helper.RequestContext.HttpContext.Response.Headers.Add("__myCustomFT", "some value");
But with no effect. The header of post never receive the parameter.

There is a way to solve this issue?

Thank you.