Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC Custom HttpHandler
    primarykey
    data
    text
    <p>I'm follow this tutorial to use CAPTCHA in MVC application: <a href="http://coderjournal.com/2008/03/actionfilterattribute-aspnet-mvc-captcha/" rel="nofollow noreferrer">http://coderjournal.com/2008/03/actionfilterattribute-aspnet-mvc-captcha/</a></p> <p>I think this was made to ealry versions of ASP.NET MVC,because it doenst work for me.</p> <p>Problem is that captcha image never shows,cause the custom handler (captcha.ashx) never gets the request.</p> <p>In web.config:</p> <pre><code>&lt;httpHandlers&gt; &lt;remove verb="*" path="*.asmx"/&gt; &lt;add verb="GET" validate="false" path="captcha.ashx" type="SCE.Models.Helpers.Captcha.CaptchaHandler"/&gt; &lt;/httpHandlers&gt; </code></pre> <p>The handler:</p> <pre><code>namespace SCE.Models.Helpers.Captcha { public class CaptchaHandler : IHttpHandler { public bool IsReusable { get { return true; } } public void ProcessRequest(HttpContext context) { string guid = context.Request.QueryString["guid"]; CaptchaImage ci = CaptchaImage.GetCachedCaptcha(guid); if (String.IsNullOrEmpty(guid) || ci == null) { context.Response.StatusCode = 404; context.Response.StatusDescription = "Not found"; context.ApplicationInstance.CompleteRequest(); return; } using (Bitmap b = ci.RenderImage()) { b.Save(context.Response.OutputStream, ImageFormat.Gif); } context.Response.ContentType = "image/png"; context.Response.StatusCode = 200; context.Response.StatusDescription = "OK"; context.ApplicationInstance.CompleteRequest(); } } } </code></pre> <p>It seem newer version of MVC has changed the way they route handler,but i dont know what exactly...</p> <p>Any ideias to call the handler?</p> <p>UPDATE: Here is the solution ive found: In global.asax file:</p> <pre><code>routes.IgnoreRoute("{filename}.ashx/{*pathInfo}"); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload