• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Urls.FriendlyUrlSettings类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DotNetNuke.Entities.Urls.FriendlyUrlSettings的典型用法代码示例。如果您正苦于以下问题:C# FriendlyUrlSettings类的具体用法?C# FriendlyUrlSettings怎么用?C# FriendlyUrlSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FriendlyUrlSettings类属于DotNetNuke.Entities.Urls命名空间,在下文中一共展示了FriendlyUrlSettings类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Log404

        /// <summary>
        /// Logs the 404 error to a table for later checking 
        /// </summary>
        /// <param name="request"></param>
        /// <param name="settings"></param>
        /// <param name="result"></param>
        public static void Log404(HttpRequest request, FriendlyUrlSettings settings, UrlAction result)
        {
            var controller = new LogController();
            var log = new LogInfo
                {
                    LogTypeKey = EventLogController.EventLogType.PAGE_NOT_FOUND_404.ToString(),
                    LogPortalID = (result.PortalAlias != null) ? result.PortalId : -1
                };
            log.LogProperties.Add(new LogDetailInfo("TabId", (result.TabId > 0) ? result.TabId.ToString() : String.Empty));
            log.LogProperties.Add(new LogDetailInfo("PortalAlias",  (result.PortalAlias != null) ? result.PortalAlias.HTTPAlias : String.Empty));
            log.LogProperties.Add(new LogDetailInfo("OriginalUrl",  result.RawUrl));

            if (request != null)
            {
                if (request.UrlReferrer != null)
                {
                    log.LogProperties.Add(new LogDetailInfo("Referer", request.UrlReferrer.AbsoluteUri));
                }
                log.LogProperties.Add(new LogDetailInfo("Url", request.Url.AbsoluteUri));
                log.LogProperties.Add(new LogDetailInfo("UserAgent", request.UserAgent));
                log.LogProperties.Add(new LogDetailInfo("HostAddress", request.UserHostAddress));
                log.LogProperties.Add(new LogDetailInfo("HostName", request.UserHostName));
            }

            controller.AddLog(log);
        }
开发者ID:uXchange,项目名称:Dnn.Platform,代码行数:32,代码来源:UrlRewriterUtils.cs


示例2: CheckForModuleProviderRedirect

 /// <summary>
 /// Checks for a redirect based on a module friendly url provider rule
 /// </summary>
 /// <param name="requestUri"></param>
 /// <param name="result"></param>
 /// <param name="queryStringCol"></param>
 /// <param name="settings"></param>
 /// <param name="parentTraceId"></param>
 /// <returns></returns>
 internal static bool CheckForModuleProviderRedirect(Uri requestUri, 
                                                         ref UrlAction result,
                                                         NameValueCollection queryStringCol,
                                                         FriendlyUrlSettings settings, 
                                                         Guid parentTraceId)
 {
     var messages = new List<string>();
     string location;
     bool redirected = ExtensionUrlProviderController.CheckForRedirect(requestUri, 
                                                                         result, 
                                                                         queryStringCol, 
                                                                         settings,
                                                                         out location, 
                                                                         ref messages, 
                                                                         parentTraceId);
     if (messages != null)
     {
         result.DebugMessages.AddRange(messages);
     }
     if (redirected)
     {
         result.FinalUrl = location;
         result.Action = ActionType.Redirect301;
         result.Reason = RedirectReason.Custom_Redirect;
     }
     return redirected;
 }
开发者ID:VegasoftTI,项目名称:Dnn.Platform,代码行数:36,代码来源:RedirectController.cs


示例3: BindAction

        public void BindAction(int portalId, int tabId, int moduleId)
        {
            var providers = ExtensionUrlProviderController.GetProviders(portalId);
			Localization.LocalizeDataGrid(ref providersGrid, LocalResourceFile);
            providersGrid.DataSource = providers;
            providersGrid.DataBind();

            UrlSettingsExtensionControl.BindAction(portalId, tabId, moduleId);

            var settings = new DotNetNuke.Entities.Urls.FriendlyUrlSettings(portalId);
            if (settings.EnableCustomProviders == false)
            {
                providersGrid.Visible = false;
                providersWarningLabel.Visible = true;
                providersWarningLabel.Text = LocalizeString("ExtensionProvidersDisabled.Text");
            }
            else
            {
                if (providersGrid.Items.Count == 0)
                {
                    providersGrid.Visible = false;
                    providersWarningLabel.Visible = true;
                    providersWarningLabel.Text = LocalizeString("NoProvidersInstalled.Text");
                }
            }
            
            
        }
开发者ID:rjallepalli,项目名称:PIX_CMS,代码行数:28,代码来源:AdvancedUrlSettings.ascx.cs


示例4: RewriteUrl

        internal override void RewriteUrl(object sender, EventArgs e)
        {
            Guid parentTraceId = Guid.Empty;
            const bool debug = true;
            bool failedInitialization = false;
            bool ignoreForInstall = false;
            var app = (HttpApplication) sender;
            try
            {
                //875 : completely ignore install/upgrade requests immediately
                ignoreForInstall = IgnoreRequestForInstall(app.Request);

                if (ignoreForInstall == false)
                {
                    _settings = new FriendlyUrlSettings(-1);

                    SecurityCheck(app);
                }
                
            }
            catch (Exception ex)
            {
                //exception handling for advanced Url Rewriting requests
                failedInitialization = true;
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                if (app.Context != null)
                {
                    ShowDebugData(app.Context, app.Request.Url.AbsoluteUri, null, ex);
                    Handle404OrException(_settings, app.Context, ex, null, false, debug);
                }
                else
                {
                    throw;
                }
            }
            if (!failedInitialization && !ignoreForInstall)
            {
                //if made it through there and not installing, go to next call.  Not in exception catch because it implements it's own top-level exception handling
                var request = app.Context.Request;

                //829 : change constructor to stop using physical path
                var result = new UrlAction(request)
                                        {
                                            IsSecureConnection = request.IsSecureConnection,
                                            IsSSLOffloaded = IsSSLOffloadEnabled(request),
                                            RawUrl = request.RawUrl
                                        };
                ProcessRequest(app.Context,
                                    app.Context.Request.Url,
                                     Host.Host.UseFriendlyUrls,
                                     result,
                                     _settings,
                                     true,
                                     parentTraceId);
            }
        }
开发者ID:davidsports,项目名称:Dnn.Platform,代码行数:56,代码来源:AdvancedUrlRewriter.cs


示例5: ProcessRequest

        private void ProcessRequest(FriendlyUrlSettings settings, UrlTestHelper testHelper)
        {
            var provider = new AdvancedUrlRewriter();

            provider.ProcessTestRequestWithContext(HttpContext.Current,
                                    HttpContext.Current.Request.Url,
                                    true,
                                    testHelper.Result,
                                    settings);
            testHelper.Response = HttpContext.Current.Response;
        }
开发者ID:hungnt-me,项目名称:Dnn.Platform,代码行数:11,代码来源:UrlRewriteTests.cs


示例6: IsExcludedFromFriendlyUrls

        /// <summary>
        /// Determines if the tab is excluded from FriendlyUrl Processing
        /// </summary>
        /// <param name="tab"></param>
        /// <param name="settings"></param>
        /// <param name="rewriting">If true, we are checking for rewriting purposes, if false, we are checking for friendly Url Generating.</param>
        /// <returns></returns>
        private static bool IsExcludedFromFriendlyUrls(TabInfo tab, FriendlyUrlSettings settings, bool rewriting)
        {
            //note this is a duplicate of another method in RewriteController.cs
            bool exclude = false;
            string tabPath = (tab.TabPath.Replace("//", "/") + ";").ToLower();
            if (settings.UseBaseFriendlyUrls != null)
            {
                exclude = settings.UseBaseFriendlyUrls.ToLower().Contains(tabPath);
            }

            return exclude;
        }
开发者ID:rut5949,项目名称:Dnn.Platform,代码行数:19,代码来源:FriendlyUrlController.cs


示例7: GetAliasByPortalIdAndSettings

 /// <summary>
 /// Returns the chosen portal alias for a specific portal Id and culture Code
 /// </summary>
 /// <param name="aliases"></param>
 /// <param name="portalId"></param>
 /// <param name="cultureCode"></param>
 /// <remarks>Detects the current browser type if possible.  If can't be deteced 'normal' is used. If a specific browser type is required, use overload with browser type.</remarks>
 /// <returns></returns>
 public static PortalAliasInfo GetAliasByPortalIdAndSettings(this IEnumerable<PortalAliasInfo> aliases, int portalId, UrlAction result, string cultureCode, FriendlyUrlSettings settings)
 {
     var browserType = BrowserTypes.Normal;
     //if required, and possible, detect browser type
     if (HttpContext.Current != null && settings != null)
     {
         HttpRequest request = HttpContext.Current.Request;
         HttpResponse response = HttpContext.Current.Response;
         browserType = FriendlyUrlController.GetBrowserType(request, response, settings);
     }
     return GetAliasByPortalIdAndSettings(aliases, portalId, result, cultureCode, browserType);
 }
开发者ID:rjallepalli,项目名称:PIX_CMS,代码行数:20,代码来源:PortalAliasExtensions.cs


示例8: GetProvidersToCall

        /// <summary>
        /// Returns the providers to call. Returns tabid matches first, and any portal id matches after that.
        /// </summary>
        /// <param name="tabId"></param>
        /// <param name="portalId"></param>
        /// <param name="settings"></param>
        /// <param name="parentTraceId"></param>
        /// <returns></returns>
        private static List<ExtensionUrlProvider> GetProvidersToCall(int tabId, 
                                                                    int portalId, 
                                                                    FriendlyUrlSettings settings,
                                                                    Guid parentTraceId)
        {
            List<ExtensionUrlProvider> providers;

            //887 : introduce lockable code to prevent caching race errors 
            lock (providersBuildLock)
            {
                bool definitelyNoProvider;
                //887 : use cached list of tabs instead of per-tab cache of provider
                //get the list of providers to call based on the tab and the portal
                var providersToCall = CacheController.GetProvidersForTabAndPortal(tabId,
                                                                                    portalId,
                                                                                    settings,
                                                                                    out definitelyNoProvider,
                                                                                    parentTraceId);
                if (definitelyNoProvider == false && providersToCall == null)
                //nothing in the cache, and we don't have a definitive 'no' that there isn't a provider
                {
                    //get all providers for the portal
                    var allProviders = GetModuleProviders(portalId).Where(p => p.ProviderConfig.IsActive).ToList();

                    //store the list of tabs for this portal that have a provider attached
                    CacheController.StoreListOfTabsWithProviders(allProviders, portalId, settings);

                    //stash the provider portals in the cache
                    CacheController.StoreModuleProvidersForPortal(portalId, settings, allProviders);

                    //now check if there is a provider for this tab/portal combination
                    if (allProviders.Count > 0)
                    {
                        //find if a module is specific to a tab
                        providersToCall = new List<ExtensionUrlProvider>();
                        providersToCall.AddRange(allProviders);
                    }
                }
                //always return an instantiated provider collection
                providers = providersToCall ?? (new List<ExtensionUrlProvider>());
            }

            //return the collection of module providers
            return providers;
        }
开发者ID:rrsc,项目名称:Dnn.Platform,代码行数:53,代码来源:ExtensionUrlProviderController.cs


示例9: CancelRedirect

 /// <summary>
 /// Cancels a redirect
 /// </summary>
 /// <param name="result"></param>
 /// <param name="context"></param>
 /// <param name="settings"></param>
 /// <param name="message"></param>
 internal static void CancelRedirect(ref UrlAction result, HttpContext context, FriendlyUrlSettings settings, string message)
 {
     result.Action = ActionType.Continue;
     result.Reason = RedirectReason.Not_Redirected;
     result.FinalUrl = null;
     //clean the path for the rewrite 
     NameValueCollection queryString = null;
     if (context != null)
     {
         queryString = context.Request.QueryString;
     }
     result.RewritePath = RedirectTokens.RemoveAnyRedirectTokens(result.RewritePath, queryString);
     //redo the rewrite to fix up the problem.  The user has ticked 'permanent redirect' but hasn't supplied a forwarding Url
     if (context != null)
     //if no context supplied, means no rewrite was required because querystring didn't contain do301 action
     {
         //RewriterUtils.RewriteUrl(context, result.RewritePath, settings.RebaseClientPath);
         RewriterUtils.RewriteUrl(context, result.RewritePath);
     }
     result.DebugMessages.Add(message);
 }
开发者ID:VegasoftTI,项目名称:Dnn.Platform,代码行数:28,代码来源:RedirectController.cs


示例10: GetOptionsFromSettings

 /// <summary>
 /// Return a FriendlyUrlOptions object from the provider settings
 /// </summary>
 /// <param name="settings"></param>
 /// <returns></returns>
 public static FriendlyUrlOptions GetOptionsFromSettings(FriendlyUrlSettings settings)
 {
     var options = new FriendlyUrlOptions
         {
             PunctuationReplacement = (settings.ReplaceSpaceWith != FriendlyUrlSettings.ReplaceSpaceWithNothing) 
                                             ? settings.ReplaceSpaceWith 
                                             : String.Empty,
             SpaceEncoding = settings.SpaceEncodingValue,
             MaxUrlPathLength = 200,
             ConvertDiacriticChars = settings.AutoAsciiConvert,
             RegexMatch = settings.RegexMatch,
             IllegalChars = settings.IllegalChars,
             ReplaceChars = settings.ReplaceChars,
             ReplaceDoubleChars = settings.ReplaceDoubleChars,
             ReplaceCharWithChar = settings.ReplaceCharacterDictionary,
             PageExtension = (settings.PageExtensionUsageType == PageExtensionUsageType.Never) 
                                     ? "" 
                                     : settings.PageExtension
         };
     return options;
 }
开发者ID:uXchange,项目名称:Dnn.Platform,代码行数:26,代码来源:UrlRewriterUtils.cs


示例11: IdentifyPortalAlias

        private void IdentifyPortalAlias(HttpContext context, 
                                            HttpRequest request, 
                                            Uri requestUri, UrlAction result,
                                            NameValueCollection queryStringCol, 
                                            FriendlyUrlSettings settings,
                                            Guid parentTraceId)
        {
            //get the domain name of the request, if it isn't already supplied
            if (request != null && string.IsNullOrEmpty(result.DomainName))
            {
                result.DomainName = Globals.GetDomainName(request); //parse the domain name out of the request
            }

            // get tabId from querystring ( this is mandatory for maintaining portal context for child portals ) 
            if (queryStringCol["tabid"] != null)
            {
                string raw = queryStringCol["tabid"];
                int tabId;
                if (Int32.TryParse(raw, out tabId))
                {
                    result.TabId = tabId;
                }
                else
                {
                    //couldn't parse tab id
                    //split in two?
                    string[] tabids = raw.Split(',');
                    if (tabids.GetUpperBound(0) > 0)
                    {
                        //hmm more than one tabid
                        if (Int32.TryParse(tabids[0], out tabId))
                        {
                            result.TabId = tabId;
                            //but we want to warn against this!
                            var ex =
                                new Exception(
                                    "Illegal request exception : Two TabId parameters provided in a single request: " +
                                    requestUri);
                            UrlRewriterUtils.LogExceptionInRequest(ex, "Not Set", result);

                            result.Ex = ex;
                        }
                        else
                        {
                            //yeah, nothing, divert to 404 
                            result.Action = ActionType.Output404;
                            var ex =
                                new Exception(
                                    "Illegal request exception : TabId parameters in query string, but invalid TabId requested : " +
                                    requestUri);
                            UrlRewriterUtils.LogExceptionInRequest(ex, "Not Set", result);
                            result.Ex = ex;
                        }
                    }
                }
            }
            // get PortalId from querystring ( this is used for host menu options as well as child portal navigation ) 
            if (queryStringCol["portalid"] != null)
            {
                string raw = queryStringCol["portalid"];
                int portalId;
                if (Int32.TryParse(raw, out portalId))
                {
                    //848 : if portal already found is different to portal id in querystring, then load up different alias
                    //this is so the portal settings will be loaded correctly.
                    if (result.PortalId != portalId)
                    {
                        //portal id different to what we expected
                        result.PortalId = portalId;
                        //check the loaded portal alias, because it might be wrong
                        if (result.PortalAlias != null && result.PortalAlias.PortalID != portalId)
                        {
                            //yes, the identified portal alias is wrong.  Find the correct alias for this portal
                            PortalAliasInfo pa = TabIndexController.GetPortalAliasByPortal(portalId, result.DomainName);
                            if (pa != null)
                            {
                                //note: sets portal id and portal alias
                                result.PortalAlias = pa;
                            }
                        }
                    }
                }
            }
            else
            {
                //check for a portal alias if there's no portal Id in the query string
                //check for absence of captcha value, because the captcha string re-uses the alias querystring value
                if (queryStringCol["alias"] != null && queryStringCol["captcha"] == null)
                {
                    string alias = queryStringCol["alias"];
                    PortalAliasInfo portalAlias = PortalAliasController.Instance.GetPortalAlias(alias);
                    if (portalAlias != null)
                    {
                        //ok the portal alias was found by the alias name
                        // check if the alias contains the domain name
                        if (alias.Contains(result.DomainName) == false)
                        {
                            // replaced to the domain defined in the alias 
                            if (request != null)
                            {
//.........这里部分代码省略.........
开发者ID:davidsports,项目名称:Dnn.Platform,代码行数:101,代码来源:AdvancedUrlRewriter.cs


示例12: ConfigurePortalAliasRedirect

 /// <summary>
 /// Configures the result object to set the correct Alias redirect
 /// parameters and destination URL
 /// </summary>
 /// <param name="result"></param>
 /// <param name="wrongAlias"></param>
 /// <param name="rightAlias"></param>
 /// <param name="ignoreCustomAliasTabs"></param>
 /// <param name="redirectReason"></param>
 /// <param name="internalAliases"></param>
 /// <param name="settings"></param>
 /// <returns></returns>
 private static bool ConfigurePortalAliasRedirect(ref UrlAction result, 
                                                     string wrongAlias, 
                                                     string rightAlias,
                                                     bool ignoreCustomAliasTabs, 
                                                     RedirectReason redirectReason,
                                                     List<InternalAlias> internalAliases,
                                                     FriendlyUrlSettings settings)
 {
     //wrong alias for the portal
     //check to see if the wrong portal alias could be a custom alias for a tab
     bool doRedirect;
     if (ignoreCustomAliasTabs == false) //check out custom alias tabs collection
     {
         //if an alias is a custom tab alias for a specific tab, then don't redirect
         if (CheckIfAliasIsCustomTabAlias(ref result, wrongAlias, settings)) 
             doRedirect = false;
         else
         {
             doRedirect = true;
         }
     }
     else
     {
         doRedirect = true; //do redirect, ignore custom alias entries for tabs
     }
     //check to see if it is an internal alias.  These are used to block redirects
     //to allow for reverse proxy requests, which must change the rewritten alias
     //while leaving the requested alias
     bool internalAliasFound = false;
     if (doRedirect && internalAliases != null && internalAliases.Count > 0)
     {
         if (internalAliases.Any(ia => String.Compare(ia.HttpAlias, wrongAlias, StringComparison.OrdinalIgnoreCase) == 0))
         {
             internalAliasFound = true;
             doRedirect = false;
         }
     }
     //if still need to do redirect, then set the settings that will cause the redirect (redirect not done here)
     if (doRedirect)
     {
         result.Action = ActionType.Redirect301;
         result.Reason = redirectReason;
         string destUrl = result.OriginalPath.Replace(wrongAlias, rightAlias);
         if (redirectReason == RedirectReason.Wrong_Portal_Alias_For_Culture ||
             redirectReason == RedirectReason.Wrong_Portal_Alias_For_Culture_And_Browser)
         {
             destUrl = destUrl.Replace("/language/" + result.CultureCode, "");
         }
         destUrl = CheckForSiteRootRedirect(rightAlias, destUrl);
         result.FinalUrl = destUrl;
     }
     else
     {
         //838 : don't overwrite the reason if already have checkfor301
         // and don't do a check on the basis that an internal alias was found
         if (result.Action != ActionType.CheckFor301 && internalAliasFound == false)
         {
             //set status to 'check for redirect'
             result.Action = ActionType.CheckFor301;
             result.Reason = RedirectReason.Custom_Tab_Alias;
         }
     }
     return doRedirect;
 }
开发者ID:davidsports,项目名称:Dnn.Platform,代码行数:76,代码来源:AdvancedUrlRewriter.cs


示例13: CheckIfAliasIsCustomTabAlias

 /// <summary>
 /// Checks to see whether the specified alias is a customTabAlias
 /// </summary>
 /// <param name="result"></param>
 /// <param name="httpAlias"></param>
 /// <param name="settings"></param>
 /// <returns></returns>
 private static bool CheckIfAliasIsCustomTabAlias(ref UrlAction result, string httpAlias, FriendlyUrlSettings settings)
 {
     List<string> customAliasesForTabs = TabIndexController.GetCustomPortalAliases(settings);
     bool isACustomTabAlias = false;
     if (customAliasesForTabs != null && customAliasesForTabs.Count > 0)
     {
         //remove any customAliases that are also primary aliases.
         foreach (var cpa in PortalAliasController.Instance.GetPortalAliasesByPortalId(result.PortalId))
         {
             if (cpa.IsPrimary == true && customAliasesForTabs.Contains(cpa.HTTPAlias))
             {
                 customAliasesForTabs.Remove(cpa.HTTPAlias);
             }
         }
         isACustomTabAlias = customAliasesForTabs.Contains(httpAlias.ToLower());
     }
     return isACustomTabAlias;
 }
开发者ID:davidsports,项目名称:Dnn.Platform,代码行数:25,代码来源:AdvancedUrlRewriter.cs


示例14: ProcessRequest

        private void ProcessRequest(HttpContext context,
                                Uri requestUri,
                                bool useFriendlyUrls,
                                UrlAction result,
                                FriendlyUrlSettings settings,
                                bool allowSettingsChange,
                                Guid parentTraceId)
        {
            bool finished = false;
            bool showDebug = false;
            bool postRequest = false;

            HttpRequest request = context.Request;
            HttpResponse response = context.Response;
            string requestType = request.RequestType;
            NameValueCollection queryStringCol = request.QueryString;

            try
            {

                string fullUrl, querystring;
                //699: get the full url based on the request and the quersytring, rather than the requestUri.ToString()
                //there is a difference in encoding, which can corrupt results when an encoded value is in the querystring
                RewriteController.GetUrlWithQuerystring(request, requestUri, out fullUrl, out querystring);

                showDebug = CheckForDebug(request, queryStringCol, settings.AllowDebugCode);
                string ignoreRegex = settings.IgnoreRegex;
                bool ignoreRequest = IgnoreRequest(result, fullUrl, ignoreRegex, request);
                bool redirectAlias = false;
                if (!ignoreRequest)
                {
                    //set original path
                    context.Items["UrlRewrite:OriginalUrl"] = requestUri.AbsoluteUri;

                    //set the path of the result object, and determine if a redirect is allowed on this request
                    result.SetOriginalPath(requestUri.ToString(), settings);
                    //737 : set the mobile browser 
                    result.SetBrowserType(request, response, settings);
                    //add to context
                    context.Items["UrlRewrite:BrowserType"] = result.BrowserType.ToString();

                    //839 : split out this check
                    result.SetRedirectAllowed(result.OriginalPath, settings);

                    //find the portal alias first
                    string wrongAlias;
                    bool isPrimaryAlias;
                    var requestedAlias = GetPortalAlias(settings, fullUrl, out redirectAlias, out isPrimaryAlias, out wrongAlias);
                    
                    if (requestedAlias != null)
                    {
                        //827 : now get the correct settings for this portal (if not a test request)
                        //839 : separate out redirect check as well and move above first redirect test (ConfigurePortalAliasRedirect)
                        if (allowSettingsChange)
                        {
                            settings = new FriendlyUrlSettings(requestedAlias.PortalID);
                            result.SetRedirectAllowed(result.OriginalPath, settings);
                        }
                        result.PortalAlias = requestedAlias;
                        result.PrimaryAlias = requestedAlias;//this is the primary alias
                        result.PortalId = requestedAlias.PortalID;
                        result.CultureCode = requestedAlias.CultureCode;
                        //get the portal alias mapping for this portal
                        result.PortalAliasMapping = PortalSettings.GetPortalAliasMappingMode(requestedAlias.PortalID);

                        //if requested alias wasn't the primary, we have a replacement, redirects are allowed and the portal alias mapping mode is redirect
                        //then do a redirect based on the wrong portal
                        if ((redirectAlias && wrongAlias != null) && result.RedirectAllowed && result.PortalAliasMapping != PortalSettings.PortalAliasMapping.Redirect)
                        {
                            //this is the alias, we are going to enforce it as the primary alias
                            result.PortalAlias = requestedAlias;
                            result.PrimaryAlias = requestedAlias;
                            //going to redirect this alias because it is incorrect
                            //or do we just want to mark as 'check for 301??'
                            redirectAlias = ConfigurePortalAliasRedirect(ref result,
                                                                            wrongAlias,
                                                                            requestedAlias.HTTPAlias,
                                                                            false,
                                                                            settings.InternalAliasList,
                                                                            settings);
                        }
                        else
                        {
                            //do not redirect the wrong alias, but set the primary alias value
                            if (wrongAlias != null)
                            {
                                //get the portal alias info for the requested alias (which is the wrong one)
                                //and set that as the alias, but also set the found alias as the primary
                                PortalAliasInfo wrongAliasInfo = PortalAliasController.Instance.GetPortalAlias(wrongAlias);
                                if (wrongAliasInfo != null)
                                {
                                    result.PortalAlias = wrongAliasInfo;
                                    result.PrimaryAlias = requestedAlias;
                                }
                                
                            }
                        }
                    }
                }
                ignoreRegex = settings.IgnoreRegex;
//.........这里部分代码省略.........
开发者ID:davidsports,项目名称:Dnn.Platform,代码行数:101,代码来源:AdvancedUrlRewriter.cs


示例15: RedirectPortalAlias

        /// <summary>
        /// Redirects an alias if that is allowed by the settings
        /// </summary>
        /// <param name="httpAlias"></param>
        /// <param name="result"></param>
        /// <param name="settings"></param>
        /// <returns></returns>

        private static bool RedirectPortalAlias(string httpAlias, ref UrlAction result, FriendlyUrlSettings settings)
        {
            bool redirected = false;
            //redirect to primary alias
            if (result.PortalAliasMapping == PortalSettings.PortalAliasMapping.Redirect && result.RedirectAllowed)
            {
                if (result.Reason == RedirectReason.Wrong_Portal_Alias_For_Browser_Type || result.Reason == RedirectReason.Wrong_Portal_Alias_For_Culture ||
                    result.Reason == RedirectReason.Wrong_Portal_Alias_For_Culture_And_Browser)
                {
                    redirected = ConfigurePortalAliasRedirect(ref result, result.HttpAlias, httpAlias, false, result.Reason, settings.InternalAliasList, settings);
                }
                else
                {
                    redirected = ConfigurePortalAliasRedirect(ref result, result.HttpAlias, httpAlias, false, settings.InternalAliasList, settings);
                }
            }

            return redirected;
        }
开发者ID:davidsports,项目名称:Dnn.Platform,代码行数:27,代码来源:AdvancedUrlRewriter.cs


示例16: IsPortalAliasIncorrect

        protected bool IsPortalAliasIncorrect(HttpContext context, 
                                                    HttpRequest request, 
                                                    Uri requestUri,
                                                    UrlAction result, 
                                                    NameValueCollection queryStringCol,
                                                    FriendlyUrlSettings settings, 
                                                    Guid parentTraceId,
                                                    out string httpAlias)
        {
            //now check to make sure it's the primary portal alias for this portal/language/browser
            bool incorrectAlias = false;
            httpAlias = null;
            //if (result.RedirectAllowed && result.PortalId > -1)
            if (result.PortalId > -1) //portal has been identified
            {
                var portalAliases = PortalAliasController.Instance.GetPortalAliasesByPortalId(result.PortalId).ToList();

                if (queryStringCol != null && queryStringCol["forceAlias"] != "true")
                {
                    if (portalAliases.Count > 0)
                    {
                        string checkAlias = result.HttpAlias;
                        bool continueLoop = true;
                        bool triedWWW = false;
                        while (httpAlias == null && continueLoop)
                        {
                            if (portalAliases.ContainsAlias(result.PortalId, checkAlias))
                            {
                                if (portalAliases.Count > 0)
                                {
                                    //var cpa = portalAliases.GetAliasByPortalIdAndSettings(result);
                                    string url = requestUri.ToString();
                                    RewriteController.CheckLanguageMatch(ref url, result);
                                    var cpa = portalAliases.GetAliasByPortalIdAndSettings(result.PortalId, result, result.CultureCode, result.BrowserType);

                                    if (cpa != null)
                                    {
                                        httpAlias = cpa.HTTPAlias;
                                        continueLoop = false;
                                    }
                                    if (String.IsNullOrEmpty(result.CultureCode) && cpa == null)
                                    {
                                        //if there is a specific culture for this portal alias, then check that
                                        string culture = portalAliases.GetCultureByPortalIdAndAlias(result.PortalId, result.HttpAlias);
                                        //if this matches the alias of the request, then we know we have the correct alias because it is a specific culture
                                        if (!string.IsNullOrEmpty(culture))
                                        {
                                            continueLoop = false;
                                        }
                                    }
                                }
                            }
                            //check whether to still go on or not
                            if (continueLoop)
                            {
                                //this alias doesn't exist in the list
                                //check if it has a www on it - if not, try adding, if it does, try removing
                                if (!triedWWW)
                                {
                                    triedWWW = true; //now tried adding/removing www
                                    if (checkAlias.ToLower().StartsWith("www."))
                                    {
                                        checkAlias = checkAlias.Substring(4);
                                    }
                                    else
                                    {
                                        checkAlias = "www." + checkAlias;
                                    }
                                }
                                else
                                {
                                    //last thing to try, get the default language and see if there is a portal alias for that
                                    //thus, any aliases not identified as belonging to a language are redirected back to the 
                                    //alias named for the default language
                                    continueLoop = false;
                                    //735 : switch to custom method for getting portal
                                    PortalInfo pi = CacheController.GetPortal(result.PortalId, false);
                                    if (pi != null)
                                    {
                                        string cultureCode = pi.DefaultLanguage;
                                        if (!string.IsNullOrEmpty(cultureCode))
                                        {
                                            var primaryPortalAlias = portalAliases.GetAliasByPortalIdAndSettings(result.PortalId, result,cultureCode,settings);
                                            if (primaryPortalAlias != null)
                                            {
                                                httpAlias = primaryPortalAlias.HTTPAlias;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    
                    //check to see if it is a custom tab alais - in that case, it is allowed to be requested for the tab
                    if (CheckIfAliasIsCustomTabAlias(ref result, httpAlias, settings))
                    {
                        //change the primary alias to the custom tab alias that has been requested.
                        result.PrimaryAlias = result.PortalAlias;
//.........这里部分代码省略.........
开发者ID:davidsports,项目名称:Dnn.Platform,代码行数:101,代码来源:AdvancedUrlRewriter.cs


示例17: GetPortalAlias

 private PortalAliasInfo GetPortalAlias(FriendlyUrlSettings settings, string requestUrl, out bool redirectAlias, out bool isPrimaryAlias, out string wrongAlias)
 {
     PortalAliasInfo alias = null;
     redirectAlias = false;
     wrongAlias = null;
     isPrimaryAlias = false;
     OrderedDictionary portalRegexes = TabIndexController.GetPortalAliasRegexes(settings);
     foreach (string regexPattern in portalRegexes.Keys)
     {
         //split out the portal alias from the regex pattern representing that alias
         Match aliasMatch = Regex.Match(requestUrl, regexPattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
         if (aliasMatch.Success)
         {
             //check for mobile browser and matching
             var aliasEx = (PortalAliasInfo)portalRegexes[regexPattern];
             redirectA 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Urls.UrlAction类代码示例发布时间:2022-05-24
下一篇:
C# Tabs.TabInfo类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap