Copied to clipboard

Flag this post as spam?

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


  • Harshwardhan Dangra 2 posts 71 karma points
    Aug 30, 2017 @ 04:13
    Harshwardhan Dangra
    0

    Redirect on external URL like http://.com when contentservice Published event is fired manually.

    Hi To All,

    Here I want to redirect on the external url like http:// when ContentService.Published event is fired from umbraco backoffice

    Below I am going to share my code

        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            ContentService.Published += ContentServicePublished;
        }
    
    
    private void ContentServicePublished(IPublishingStrategy sender, PublishEventArgs<IContent> args)
        {
            try
            {  
                var context = UmbracoContext.Current;
                context.HttpContext.Response.Redirect("http://");
            }
            catch (Exception ex)
            {
                var result = JsonConvert.SerializeObject(ex);
            }
        }
    
Please Sign in or register to post replies

Write your reply to:

Draft