Note that there are some explanatory texts on larger screens.

plurals
  1. POhttp handler does no work in MVC IIS 8.0
    primarykey
    data
    text
    <p>i want to add http handler for my captcha in my mvc website and add this to webconfig </p> <pre><code> &lt;system.webServer&gt; &lt;handlers&gt; &lt;add name="HandlerName" path="captcha.ashx" verb="*" type="ManagedFusion.Web.Handlers.CaptchaImageHandler" resourceType="Unspecified" /&gt; &lt;/handlers&gt; &lt;/system.webServer&gt; </code></pre> <p>but my Captcha Image does not show and when i see this url "<code>http://localhost:2492/captcha.ashx</code>" i get this error "The resource cannot be found"</p> <p>this is my globals.asax</p> <pre><code>public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); routes.IgnoreRoute("{resource}/{any}.ashx"); routes.IgnoreRoute("{any}.ashx"); routes.IgnoreRoute("captcha.ashx"); } </code></pre> <p>what's wrong ? </p> <p>Update : this is my handler implementation : </p> <pre><code> public class CaptchaImageHandler : IHttpHandler { #region IHttpHandler Members /// &lt;summary&gt; /// Gets a value indicating whether another request can use the &lt;see cref="T:System.Web.IHttpHandler"/&gt; instance. /// &lt;/summary&gt; /// &lt;value&gt;&lt;/value&gt; /// &lt;returns&gt;true if the &lt;see cref="T:System.Web.IHttpHandler"/&gt; instance is reusable; otherwise, false.&lt;/returns&gt; public bool IsReusable { get { return true; } } /// &lt;summary&gt; /// Enables processing of HTTP Web requests by a custom HttpHandler that implements the &lt;see cref="T:System.Web.IHttpHandler"/&gt; interface. /// &lt;/summary&gt; /// &lt;param name="filterContext"&gt;An &lt;see cref="T:System.Web.HttpContext"/&gt; object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.&lt;/param&gt; public void ProcessRequest(HttpContext context) { // get the unique GUID of the captcha; this must be passed in via the querystring 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.Response.End(); return; } // write the image to the HTTP output stream as an array of bytes using (Bitmap b = ci.RenderImage()) { b.Save(context.Response.OutputStream, ImageFormat.Gif); } context.Response.ContentType = "image/gif"; context.Response.StatusCode = 200; context.Response.StatusDescription = "OK"; context.Response.End(); } #endregion public void Dispose() { throw new NotImplementedException(); } public void Init(HttpApplication context) { } } } </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.
    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