+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / HTTP Handler for Classic ASP not working SiteFinity 6.2

HTTP Handler for Classic ASP not working SiteFinity 6.2

10 posts, 0 answered
  1. Hersh
    Hersh avatar
    2 posts
    Registered:
    11 Oct 2011
    05 Mar 2014
    Link to this post

    Please find our code for HTTP handler to handle classic asp request. However it request never gets processed.

     

        public class AspRouteHandler : Telerik.Sitefinity.Web.PageRouteHandler
        {
            public IHttpHandler GetHttpHandler(RequestContext requestContext)
            {
                return new LegacyUrlHandler();
            }
        }

        public class LegacyUrlHandler : IHttpHandler
        {
            private const string LegacyUrl = "index.asp";
            private const string ReferringUrl = "ReferringUrl";
            private const string RedirectUrl = "RedirectUrl";

            public void ProcessRequest(HttpContext context)
            {
                if (!context.Request.RawUrl.ToLower().Contains(LegacyUrl))
                {
                    return;
                }

                IQueryable<DynamicContent> entries =
                    Extensions.RetrieveCollectionOfModuleData(DynamicModulesPath.DynamicProvider(),
                        DynamicModulesPath.Custom404());

                DynamicContent firstRow =
                    entries.FirstOrDefault(x => x.GetValue<string>(ReferringUrl) == context.Request.RawUrl);

                if (firstRow == null)
                {
                    return;
                }

                context.Response.Redirect(firstRow.GetValue(RedirectUrl).ToString());
            }

            public bool IsReusable
            {
                get { return true; }
            }
        }

    -----------------------

    Global.ascx changes

      protected void Application_Start(object sender, EventArgs e)
            {
                Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
            }

    void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs args)
            {
                if (args.CommandName == "RegisterRoutes")
                {
                    var routes = ((EnumerableQuery<System.Web.Routing.RouteBase>)args.Data).ToList<System.Web.Routing.RouteBase>();
                    System.Web.Routing.Route newRoute = new System.Web.Routing.Route("index.asp", new AspRouteHandler());
                    routes.Insert(0, newRoute);
                }
            }

    ----- web.config

    <add verb="GET" path="*.asp" type="Qualico.Website.LegacyUrlHandler, Qualico.Website"/>

  2. Hersh
    Hersh avatar
    2 posts
    Registered:
    11 Oct 2011
    05 Mar 2014 in reply to Hersh
    Link to this post

    The code handler never get's executed on the Sitefinity Web Server with IIS 8.5 however works locally due to the ASP http handler in the web.config file

  3. Vassil Vassilev
     Vassil Vassilev avatar
    308 posts
    Registered:
    21 Jan 2015
    07 Mar 2014
    Link to this post
    Hello Hersh,

    This issue is discussed here:
    http://www.sitefinity.com/developer-network/forums/general-discussions-/httphandler-not-working#1501414

    You can try set it up as is described there.

    Regards,
    Vassil Vassilev
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
  4. Hersh
    Hersh avatar
    3 posts
    Registered:
    06 Mar 2014
    07 Mar 2014 in reply to Vassil Vassilev
    Link to this post

    Hello Vassil,

     We looked the exact same blog you are pointing to to write this code. However, the handler never gets called. We have simplified the code for you. Can you please run this and see if it works for you. 

    Thanks

      public class AspRouteHandler : Telerik.Sitefinity.Web.PageRouteHandler
        {
            public IHttpHandler GetHttpHandler(RequestContext requestContext)
            {
                return new LegacyUrlHandler();
            }
        }

        public class LegacyUrlHandler : IHttpHandler
        {
            private const string LegacyUrl = "index.asp";
            private const string ReferringUrl = "ReferringUrl";
            private const string RedirectUrl = "RedirectUrl";

            public void ProcessRequest(HttpContext context)
            {
                if (!context.Request.RawUrl.ToLower().Contains(LegacyUrl))
                {
                    return;
                }

                context.Response.Redirect("/home");
            }

            public bool IsReusable
            {
                get { return true; }
            }
        }

    -----------------------

    Global.ascx changes

      protected void Application_Start(object sender, EventArgs e)
            {
                Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
            }

    void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs args)
            {
                if (args.CommandName == "RegisterRoutes")
                {
                    var routes = ((EnumerableQuery<System.Web.Routing.RouteBase>)args.Data).ToList<System.Web.Routing.RouteBase>();
                    System.Web.Routing.Route newRoute = new System.Web.Routing.Route("index.asp", new AspRouteHandler());
                    routes.Insert(0, newRoute);
                }
            }

    ----- web.config

    <add verb="GET" path="*.asp" type="Qualico.Website.LegacyUrlHandler, Qualico.Website"/>

  5. Vassil Vassilev
     Vassil Vassilev avatar
    308 posts
    Registered:
    21 Jan 2015
    12 Mar 2014
    Link to this post
    Hello Hersh,

    I have tested it and it works as expected. Make sure you have registered the handler in the proper section of your webconfig: configuration > system.webServer > handlers

    Regards,
    Vassil Vassilev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  6. Hersh
    Hersh avatar
    3 posts
    Registered:
    06 Mar 2014
    12 Mar 2014 in reply to Vassil Vassilev
    Link to this post

    We did add the handler in web.config. It has always worked locally but does not work when deployed to the web server on Windows 2012 IIS 8.5

     Thanks

    Hersh

  7. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    12 Mar 2014 in reply to Hersh
    Link to this post
    Are you 1000% sure it's not in <httpHandlers> ...because that will defiantly not work on Server 2012 IIS 8.5
  8. Vassil Vassilev
     Vassil Vassilev avatar
    308 posts
    Registered:
    21 Jan 2015
    12 Mar 2014
    Link to this post
    Hello,

    Yes, I have tested it as described and recorded a video for your convenience (video). If this works on specific environments, than the issue is related with the environment setup and is not directly related with Sitefinity.

    Regards,
    Vassil Vassilev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  9. Vassil Vassilev
     Vassil Vassilev avatar
    308 posts
    Registered:
    21 Jan 2015
    12 Mar 2014
    Link to this post
    Just a quick follow up:

    If you feel unsure where to add your HTTP handler, you could use IIS built-in tool (screenshot) to add it for you in your webconfig file.

    I hope this helps.

    Regards,
    Vassil Vassilev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  10. Hersh
    Hersh avatar
    3 posts
    Registered:
    06 Mar 2014
    13 Mar 2014 in reply to Vassil Vassilev
    Link to this post

    Thank you all. Registering the handler in the "handler" section fixed the issue.

     

     

10 posts, 0 answered