public async Task Invoke(RenderContext context)
        {
            FrontContext kooboocontext = new FrontContext(context);

            if (context.WebSite != null)
            {
                if (!Kooboo.Web.Security.AccessControl.HasWebsiteAccess(context.WebSite, context))
                {
                    if (!CheckIsBackEndOrImageUrl(kooboocontext.RenderContext.Request.RelativeUrl))
                    {
                        if (context.User == null)
                        {
                            context.Response.Redirect(302, "/_admin/account/login?type=site&returnurl=" + System.Web.HttpUtility.UrlEncode(context.Request.RawRelativeUrl));
                            context.Response.End = true;
                            return;
                        }
                        else
                        {
                            context.Response.Redirect(302, Kooboo.DataConstants.Default403Page);
                            context.Response.End = true;
                            return;
                        }
                    }
                }


                if (kooboocontext.RenderContext.IsSiteBinding || !CheckIsBackEndOrImageUrl(kooboocontext.RenderContext.Request.RelativeUrl))
                {
                    ObjectRoute.Parse(kooboocontext);
                    if (kooboocontext.Route != null && kooboocontext.Route.objectId != default(Guid))
                    {
                        var success = AuthenticationHelper.Authentication(kooboocontext);
                        if (success)
                        {
                            await ExecuteKooboo(kooboocontext);
                        }
                        return;
                    }
                }


                if (kooboocontext.Route == null && !String.IsNullOrEmpty(kooboocontext.WebSite.LocalRootPath))
                {
                    await Next.Invoke(context);

                    return;
                }

                if (!CheckIsBackEndOrImageUrl(kooboocontext.RenderContext.Request.RelativeUrl))
                {
                    if (kooboocontext.Route == null || kooboocontext.Route.objectId == default(Guid))
                    {
                        if (kooboocontext.SiteDb.WebSite.ContinueDownload)
                        {
                            if (Data.AppSettings.IsOnlineServer && !Kooboo.Web.Security.ActionControl.CanServerDownloadMorePages(kooboocontext.SiteDb, kooboocontext.RenderContext.Request.RelativeUrl))
                            {
                                kooboocontext.RenderContext.Response.StatusCode = 402;
                                var errorbody = await WebSiteService.RenderCustomError(kooboocontext, 402);

                                if (!string.IsNullOrWhiteSpace(errorbody))
                                {
                                    kooboocontext.RenderContext.Response.Body = System.Text.Encoding.UTF8.GetBytes(errorbody);
                                }
                                return;
                            }
                            else
                            {
                                var continuedownload = await TransferManager.continueDownload(kooboocontext.SiteDb, kooboocontext.RenderContext.Request.RawRelativeUrl, kooboocontext.RenderContext);

                                if (continuedownload != null)
                                {
                                    ObjectRoute.Parse(kooboocontext);
                                }
                            }
                        }
                    }

                    if (kooboocontext.Route != null && kooboocontext.Route.objectId != default(Guid))
                    {
                        await ExecuteKooboo(kooboocontext);

                        return;
                    }
                    else
                    {
                        kooboocontext.RenderContext.Response.StatusCode = 404;
                        var errorbody = await WebSiteService.RenderCustomError(kooboocontext, 404);

                        if (!string.IsNullOrWhiteSpace(errorbody))
                        {
                            kooboocontext.RenderContext.Response.Body = System.Text.Encoding.UTF8.GetBytes(errorbody);
                        }
                        return;
                    }
                }
                else
                {
                    // reensure siteid... in case of the same url used for login.
                    var siteid = Kooboo.Data.Context.WebServerContext.RequestSiteId(context.Request);
                    if (siteid != kooboocontext.RenderContext.WebSite.Id)
                    {
                        var site = Kooboo.Data.GlobalDb.WebSites.Get(siteid);
                        if (site != null)
                        {
                            kooboocontext.WebSite = site;
                        }
                    }
                }
            }

            if (RenderThumbnail(kooboocontext))
            {
                return;
            }

            // access control for allow users...
            await Next.Invoke(context);
        }