0

The CAPTCHA I'm using works fine on my local machine. However, when I import it to my web server with IIS8.5, it fails to show the image.

I'm using the basic process shown in: http://www.codeproject.com/Articles/169371/Captcha-Image-using-C-in-ASP-NET

Essentially, I'm using the asp:Image control which links to the CImage.aspx page. On page load, the CImage.aspx page generates a CAPTCHA jpg. I've found online that I likely need to do something with the IIS Handler Mappings but I really can't make heads or tails of it. Any advice would be greatly appreciated. Thanks!

vercingortix
  • 199
  • 2
  • 15
  • do you change your headers in CImage.aspx to represent that the response is an image? – MaxOvrdrv Dec 22 '15 at 19:25
  • I don't believe so. So the asp:Image control is on pages like ContactUs.aspx or Register.aspx. The ImageUrl property of those controls references "~/CImage.aspx". – vercingortix Dec 22 '15 at 19:28
  • try changing the headers so that the response is an image... a typical ImageUrl would be something like this: www.SomeSite.com/SomeFolder/SomeImage.jpg --> not a .Html or .Aspx extension. This can still work using a .aspx extension, as long as the response header reflects the right file type. See here for example (don't look at ashx responses): http://stackoverflow.com/questions/2253228/asp-net-return-image-from-aspx-link – MaxOvrdrv Dec 22 '15 at 19:32
  • My code-behind on the CImage.aspx page already sets the response contenttype to a jpeg and sends it directly to the browser using the output stream. – vercingortix Dec 22 '15 at 20:04
  • and it's not working? make sure it's the same file type (e.g.: image/png vs image/jpg... ) they should match... but if you're doing it right, then i believe it should work correctly. – MaxOvrdrv Dec 22 '15 at 20:08
  • Well, it does work. Just only in my local environment (testing through Visual Studio 2013 so I believe IIS express). However, on my web server with IIS8.5, it does not show. – vercingortix Dec 22 '15 at 20:10
  • Does your IIS server have external/internet access? – MaxOvrdrv Dec 22 '15 at 23:30
  • Its only internal on the IIS server. – vercingortix Dec 23 '15 at 14:51
  • your captcha images are all on your local server? – MaxOvrdrv Dec 23 '15 at 15:12
  • Yes and no.... The captcha images are dynamically regenerated upon each page load event. The images are saved right to the output stream so they're never physically on my IIS server. – vercingortix Dec 23 '15 at 16:53
  • Ok but where are they geberated from? They have to come from somewhere... and if that's the Internet, then you have to have access to it for it to work. – MaxOvrdrv Dec 23 '15 at 21:03

0 Answers0