Copied to clipboard

Flag this post as spam?

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


  • Pete 213 posts 285 karma points
    Nov 21, 2019 @ 16:38
    Pete
    0

    how to create httphandler in umbraco v 8

    How do you do a IHttpHandler in v8?

    I used IHttpHandler in v7 and it works ok, this is my v8.1.3 code, it doesn't get hit on a debug break.

    namespace mysite
    {
        public class CustomHttpHandler : UmbracoHttpHandler
        {
            //public CustomHttpHandler() { }
            public void Dispose() { }
            //public override bool IsReusable => false;
            public override bool IsReusable //IHttpHandler.IsReusable
            {
                get { return false; }
            }
    
            // void IHttpHandler.ProcessRequest(HttpContext context)
            public override void ProcessRequest(HttpContext context)
            {
                var path = context.Request.Url.AbsolutePath.ToLower();
                var path2 = context.Request.Url.AbsoluteUri;
                Uri address8 = new Uri(path);
                if (address8.Scheme == Uri.UriSchemeHttps)
                {
    
                }
                else
                {
                    context.Response.Redirect("");
                }
            }
        }
    }
    
  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Nov 21, 2019 @ 22:09
    Marc Goodson
    0

    Hi Pete

    What path are you mapping to the handler in the web.config?

    I've seen a similar issue before with the extension of path, not being considered as a backoffice request.

    If you make the path end with the extension .axd does this trigger your handler correctly...

    This is the issue where I remember this being discussed: https://github.com/umbraco/Umbraco-CMS/issues/6018

    Also would it be viable to 'map an mvc route' for the request instead of using then handler (obviously depends on what you are trying to achieve)

    regards

    Marc

  • Pete 213 posts 285 karma points
    Nov 22, 2019 @ 13:39
    Pete
    0

    Hi Marc

    I may be going down the wrong route here, I have a site where the host does not support the IIS url rewrite module, and we need to redirect http to https. Normally I just a rewrite rule.

    Any ideas on best way to do it without the rewrite module in v8?

    Peter

Please Sign in or register to post replies

Write your reply to:

Draft