dimanche 28 juin 2015

Custom routehandler not working in mvc3

Hi i want to make a custom route handler. its saying the resource cannot be found. here is my code in global.ascx

routes.Add(new Route("Key/{id}-{type}.jpg", new RouteKeyHandler()));

and RouteKeyHandler code

  public class RouteKeyHandler:IRouteHandler
{ 
    public IHttpHandler GetHttpHandler(RequestContext requestContext)
    {
        RouteKeyHandler httpHandler = new RouteKeyHandler();
        return httpHandler;
    }   
    public class RouteKeyHandler : IHttpHandler
    {  
        public bool IsReusable
        {
            get { return true; }
        }

        public void ProcessRequest(HttpContext context)
        {
            var routeValues = context.Request.RequestContext.RouteData.Values;               
        } 
    }
}

when i set url to localhost/Key/17-news.jpg it gives error

The resource cannot be found.

Aucun commentaire:

Enregistrer un commentaire