2

I'm trying to get an existing .net webforms site to work behind Cloudfront but all the webforms break.

Looking deeper -- the site displays fine, but webforms break because the <script src="/WebResource.axd?[...]"> is completely missing. Not 404 -- missing -- the script tag is completely missing from the html response.

This seems to be that .NET sniffs browser and responds with a custom build of WebResource.axd for that particular browser+page.

If no browser match is found. No WebResource.axd.

Doing curl http://some-aspnet-webforms-site.example.com/form.aspx also seems to confirm this. No WebResource.axd included.

How do I get Cloudfront to spoof the end-user's browser so WebResource.axd gets included? (Forwarding cookies and querystring doesn't seem to work and forwarding all headers seems to break cloudfront.)

Or at the very least, how do I force .net to always inject/insert WebResource.axd even when sniffing fails?

Community
  • 1
  • 1
Cory Mawhorter
  • 1,583
  • 18
  • 22

1 Answers1

3

The solution was to edit the Cloudfront distribution > Behavior > .net webforms behavior -- and forward headers "Whitelist"; enter only User-Agent. And of course, forward cookies and optionally querystring.

enter image description here

It seems like WebResource is compiled purely based on user agent.

Specifically forwarding user-agent fixed the issue and webforms are back to working.

Forwarding "All" headers in Cloudfront was breaking something. I don't know what/where broke by forwarding all headers, but it gave generic AWS "Access Denied" xml error pages.

Community
  • 1
  • 1
Cory Mawhorter
  • 1,583
  • 18
  • 22
  • Just found this in the docs "CloudFront replaces the value of [the User-Agent] header field with Amazon CloudFront.": http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/RequestAndResponseBehaviorCustomOrigin.html#request-custom-headers-behavior – Cory Mawhorter Oct 08 '15 at 17:41