Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • J 447 posts 864 karma points
    Feb 17, 2017 @ 15:04
    J
    0

    How to configure ashx

    I've created an ashx handler inside a Class project - heres the structure

    Class Project > Service > MyHandler.ashx

    Service = folder and MyHandler.ashx is an ashx file with some code.

    I would like to be able to visit this ashx from a browser using the URL http://localhost/handlers/myhandler.ashx

    I created a node within umbraco but not sure how i register the handler and create the above URL?

  • Marc Goodson 2157 posts 14434 karma points MVP 9x c-trib
    Feb 18, 2017 @ 08:38
    Marc Goodson
    0

    Hi J

    If you create the .ashx in your website project, then the handler will be hit if you request the path to that file, without configuration.

    The logic/code the handler then executes could then be called from the class library project

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Write("Hello World");
    
            var mycustomservice = new MyClassLibrary.SuperDoSomethingService();
            var stuff = mycustomservice.DoOrGetSomething();
            //etc
        }
    
  • Micha Somers 134 posts 597 karma points
    Feb 18, 2017 @ 13:17
    Micha Somers
    0

    With regards to handlers, I am not sure what you exactly mean with "I created a node within Umbraco".

    In order to call your .ashx handler, Umbraco should not process your handlers path the default way (searching for a content node).

    To prevent Umbraco processing that path, you need to add it to the umbracoReservedPath in the web.config file:

    <appSettings>
        <add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/handlers/" />
    ...
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies