开发者

ASHX renders as broken image

开发者 https://www.devze.com 2023-02-23 07:53 出处:网络
I\'ve got a really vexxing problem with an ASHX handler that renders a captcha image.The thing that makes it really vexxing is that it was working fine two months ago and when I went back to it again

I've got a really vexxing problem with an ASHX handler that renders a captcha image. The thing that makes it really vexxing is that it was working fine two months ago and when I went back to it again today it had stopped working.

What I've got is a page that throws in a captcha every so often. This is the markup from an example of a challenge:

<img class="challengedtl" src="Challenge.ashx?tkn=0057ea27-4d35-4850-9c6f-7a6fdc9818e2"/>

The GUID references a record in a SQL table that contains the actual content of the captcha as well as the status of the captcha challenge, i.e. has it been processed and if so did the user get it right etc.

On the page where this markup is found, the image displays as a broken jpeg. When I drop a breakpoint in the ASHX ProcessRequest() method I can see that the ASHX is never being called.

When I take the URL out of the source attribute and run it directly from the address bar in my browser, then I hit my break point in ProcessRequest and the captch image is rendered just fine.

I don't believe that my ASHX code is the problem, since it works when I call it directly. The problem seems to be with why the ASHX isn't being called by the main page. Given that this was working in February I am at a loss to explain what is going on.

I know that something has happened to my machine since then. I suspect a Windows Update or a service pack for something. The reason for this is that my captcha processing includes tracking the IP address of the caller. Back when this was working my local host was being registered as 127.0.0.1 (IPv4) but now it is being registered as ::1 (IPv6). Probably a red 开发者_如何学JAVAherring.

Does anyone know what might be causing this or do you have any suggestions for how to troubleshoot this problem?


Is the handler in the same folder as the page containing the html you posted above?


Here are the two key parts:

When I drop a breakpoint in the ASHX ProcessRequest() method I can see that the ASHX is never being called.

and

src="Challenge.ashx?tkn=0057ea27-4d35-4850-9c6f-7a6fdc9818e2"

Put those together, and what we can surmise that the path in your src attribute is wrong.

It's just an image tag. If the html loads it will send a request for that resource. Since your breakpoint is not hit, it can only mean that either you aren't testing somewhere that allows breakpoints or that it's sending the request to the wrong place.

It could be as simple as sending the request to the production version of the site, using the wrong schema (ie: https vs http), or missing a folder or port number somewhere. The browser should be able to give you the entire path of the resource -- make sure this matches what you expect.

0

精彩评论

暂无评论...
验证码 换一张
取 消