Copied to clipboard

Flag this post as spam?

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


  • Nurhak Kaya 53 posts 147 karma points MVP 2x c-trib
    Nov 07, 2016 @ 13:17
    Nurhak Kaya
    0

    Umbraco Preview not showing the correct content

    Hello,

    When I have the following key in my web.config, umbraco preview is working fine, showing me the correct content but I can not login to my web site, I can login to umbraco backoffice without any problem.

    When I comment out the following key, then I can login to my web site but this time umbraco preview is not showing the correct content.

    What should I do to make preview work and at the same time I can login to my front end site? I have already searched for a solution, but I haven't managed to fix this so far. Any help is appreciated.

    Umbraco version 7.4.3 assembly: 1.0.5948.18141

    The key:

    <add key="owin:appStartup" value="UmbracoDefaultOwinStartup" />
    

    My OwinStartup class:

    [assembly: OwinStartup(typeof(OwinStartup), "Configuration")]
    namespace Bit10.IAA.Site
    {
        public class OwinStartup : UmbracoDefaultOwinStartup
        {
            public override void Configuration(IAppBuilder app)
            {
                base.Configuration(app);
    
                app.UseCookieAuthentication(new CookieAuthenticationOptions
                {
                    AuthenticationType = "Cookies"
                });
    
                app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions());
    
    
                app.Use((context, next) =>
                {
                    var loggedInMarkerCookie = context.Request.Cookies[Settings.CookieLoggedInMarkerName];
                    var autoLoginAttempt = context.Request.Cookies[Settings.CookieLoggedInMarkerAttemptName];
    
                    if (!context.Authentication.User.Identity.IsAuthenticated && !context.Request.Path.Value.StartsWith("/sso/") && (loggedInMarkerCookie != null && autoLoginAttempt == null))
                    {
                        context.Response.Cookies.Append(Settings.CookieLoggedInMarkerAttemptName, DateTime.Now.ToString(), new CookieOptions { Expires = DateTime.Now.AddMinutes(30) });
                        context.Authentication.Challenge();
                    }
    
                    return next.Invoke();
                });
            }
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft