Copied to clipboard

Flag this post as spam?

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


  • Giu 23 posts 141 karma points
    Jan 23, 2018 @ 15:32
    Giu
    0

    OWIN startup issue with Umbraco Cloud

    In our current project, we are using the Hangfire library (1.6.17) - the lib has a OWIN dependency (1.0.0).

    Here is the code to call the hangfire launch:

    using Microsoft.Owin;
    using Owin;
    using Umbraco.Web;
    using Hangfire;
    using Hangfire.Dashboard;
    using Hangfire.Annotations;
    using Umbraco.Core.Models;
    using Umbraco.Core;
    using System.Web;
    
    [assembly: OwinStartup(typeof(XX.Web.Core.Startup))]
    namespace XX.Web.Core
    {
        public class Startup : UmbracoDefaultOwinStartup
        {
            public override void Configuration(IAppBuilder app)
            {
                //ensure the default options are configured
                base.Configuration(app);
    
                var cs = Umbraco.Core.ApplicationContext.Current.DatabaseContext.ConnectionString;
    
                GlobalConfiguration.Configuration.UseSqlServerStorage(cs);
    
                app.UseHangfireDashboard("/umbraco/backoffice/hangfire", new DashboardOptions
                {
                    Authorization = new[] { new UmbracoUserAuthorisedFilter() },
                    AppPath = "/Umbraco"
                });
    
                app.UseHangfireServer();
            }
        }
    
        public class UmbracoUserAuthorisedFilter : IDashboardAuthorizationFilter
        {
            public bool Authorize([NotNull] DashboardContext context)
            {
                // In case you need an OWIN context, use the next line,
                // `OwinContext` class is the part of the `Microsoft.Owin` package.
                //var context = new OwinContext(owinEnvironment);
    
                // Allow all authenticated users to see the Dashboard (potentially dangerous).
                //return context.Authentication.User.Identity.IsAuthenticated;
    
                //this if you want to lock down to admins only
                var userService = ApplicationContext.Current.Services.UserService;
                var user = userService.GetByUsername(HttpContext.Current.User.Identity.Name);
    
                return user.IsAdmin();
                //this if you just want to make sure user is logged into backoffice
                //return UmbracoContext.Current.Security.CurrentUser != null;
            }
        }
    }
    

    This is the default hangfire startup code to be able to use the library. The code has been working fine on 2 local machines, one Azure Web App instance but when I push this code to the Umbraco Cloud branch I get the following error:

    Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.

    The issue is: we are not using .net standard, both projects (web and core) are using .net framework 4.6.2

    Is there any workaround for that issue ?

  • Giu 23 posts 141 karma points
    Feb 01, 2018 @ 16:03
    Giu
    100

    I found out the issue .. the build had a dll called FluentEmail.Core that was causing the issue .. it looks like it's not supported in Umbraco Cloud

  • Nik 1593 posts 7151 karma points MVP 6x c-trib
    Feb 01, 2018 @ 17:25
    Nik
    0

    Which version of Hangfire are you using I've got Hangfire in a cloud app and it's working fine. I don't have the requirement of FluentEmail.Core is that a separate tool?

Please Sign in or register to post replies

Write your reply to:

Draft