Exemple #1
0
        internal sealed override string GetUrl(bool ensureUserCanAccessResource, bool ensureResourceNotDisabled)
        {
            string getCanonicalUrl() => UrlHandlingStatics.GetCanonicalUrl(this, ShouldBeSecureGivenCurrentRequest);

            var url = (EwfApp.Instance != null && EwfApp.Instance.RequestState != null
                                            ? EwfApp.Instance.RequestState.ExecuteWithUserDisabled(getCanonicalUrl)
                                            : getCanonicalUrl()) + uriFragmentIdentifier.PrependDelimiter("#");

            if (ensureUserCanAccessResource && !UserCanAccessResource)
            {
                throw new ApplicationException("GetUrl was called for a resource that the authenticated user cannot access. The URL would have been " + url + ".");
            }
            if (ensureResourceNotDisabled && AlternativeMode is DisabledResourceMode)
            {
                throw new ApplicationException("GetUrl was called for a resource that is disabled. The URL would have been " + url + ".");
            }

            return(url);
        }