I have a simple ASP.Net website that accepts an HTTP Post and saves a file to a folder.
The webpage itself looks for an "Authorization" HTTP header.
I have created a simple C# app that uploads does an HTTP Post to upload a file:
using (var client = new WebClient())
{
client.Headers.Add(HttpRequestHeader.Authorization,
"Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("username:password")));
client.Headers.Add("TestHeader", "test");
client.Headers.Add("FileName", "RRO_D_VI_DLCRS_PPERASV02000000__01_02_001_91772ef0-e758-4886-b070-4db4cafe5366.gz");
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
byte[] result = client.UploadFile(url, fileToUpload);
string responseAsString = Encoding.Default.GetString(result);
}
When the website is running on my local PC and I run my test program it works correctly. When I run the website from a QA server (Windows Server 2003) and I run my test program it works correctly.
However, when I run the website from a production server (accessed via a VPN) (Windows Server 2003 and IIS6) the "Authorization" header is completely missing. All other HTTP headers that I set are visible but the Authorization Header has been completely removed.
I also tested it using Fiddler's Composer with the same results. I have another person try to access the website from a completely separate network (that doesn't use the VPN) and they got the same results.
What would cause the Authorization HTTP header to be removed? Any ideas?
Thanks!
UPDATE* Ok, I found out the problem. I am sending the POST to www.MyDomain.com and the default page for the website is Default.aspx. If I send the request to www.MyDomain.com/Default.aspx it works fine. How can I get the Authorization Header to be forwarded to Default.aspx when the request goes to www.MyDomain.com?