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

C# Urls.UrlAction类代码示例

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

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



UrlAction类属于DotNetNuke.Entities.Urls命名空间,在下文中一共展示了UrlAction类的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: GetAliasByPortalIdAndSettings

        /// <summary>
        /// Returns a ChosenPortalAlias object where the portalId, culture code and isMobile matches
        /// </summary>
        /// <param name="aliases"></param>
        /// <param name="portalId"></param>
        /// <param name="result"></param>
        /// <param name="cultureCode"></param>
        /// <param name="browserType"></param>
        /// <returns>A ChosenPOrtalAlias</returns>
        /// <remarks>Note will return a best-match by portal if no specific culture Code match found</remarks>
        public static PortalAliasInfo GetAliasByPortalIdAndSettings(this IEnumerable<PortalAliasInfo> aliases, int portalId, UrlAction result, string cultureCode, BrowserTypes browserType)
        {
            var aliasList = aliases.ToList();

            var defaultAlias = aliasList.ToList().Where(a => a.PortalID == portalId)
                                        .OrderByDescending(a => a.IsPrimary)
                                        .FirstOrDefault();

            //27138 : Redirect loop caused by duplicate primary aliases.  Changed to only check by browserType/Culture code which makes a primary alias
            var foundAlias = aliasList.Where(a => a.BrowserType == browserType
                                            && (String.Compare(a.CultureCode, cultureCode, StringComparison.OrdinalIgnoreCase) == 0 || String.IsNullOrEmpty(a.CultureCode))
                                            && a.PortalID == portalId)
                        .OrderByDescending(a => a.IsPrimary)
                        .ThenByDescending(a => a.CultureCode)
                        .FirstOrDefault();

			//JIRA DNN-4882 : DevPCI fix bug with url Mobile -> Search alias with culture code
			// START DNN-4882
            if (foundAlias == null)
            {
                foundAlias = aliasList.Where(a => (String.Compare(a.CultureCode, cultureCode, StringComparison.OrdinalIgnoreCase) == 0 || String.IsNullOrEmpty(a.CultureCode))
                                           && a.PortalID == portalId)
					   .OrderByDescending(a => a.IsPrimary)
					   .ThenByDescending(a => a.CultureCode)
					   .FirstOrDefault();
            }
            // END DNN-4882
		
            if (foundAlias != null)
            {
                if(result !=null && result.PortalAlias != null)
                {
                    if (foundAlias.BrowserType != result.PortalAlias.BrowserType)
                    {
                        result.Reason = foundAlias.CultureCode != result.PortalAlias.CultureCode 
                            ? RedirectReason.Wrong_Portal_Alias_For_Culture_And_Browser 
                            : RedirectReason.Wrong_Portal_Alias_For_Browser_Type;
                    }
                    else
                    {
                        if (foundAlias.CultureCode != result.PortalAlias.CultureCode)
                        {
                            result.Reason = RedirectReason.Wrong_Portal_Alias_For_Culture;
                        }
                    }
                }
            }
            else
            {
                foundAlias = defaultAlias;
            }

            //if we didn't find a specific match, return the default, which is the closest match
            return foundAlias;
        }
开发者ID:davidsports,项目名称:Dnn.Platform,代码行数:65,代码来源:PortalAliasExtensions.cs


示例4: 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


示例5: 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


示例6: ShowDebugData

        private static void ShowDebugData(HttpContext context, string requestUri, UrlAction result, Exception ex)
        {
            if (context != null)
            {
                HttpResponse response = context.Response;

                //handle null responses wherever they might be found - this routine must be tolerant to all kinds of invalid inputs
                if (requestUri == null)
                {
                    requestUri = "null Uri";
                }
                string finalUrl = "null final Url";
                string rewritePath = "null rewrite path";
                string action = "null action";
                if (result != null)
                {
                    finalUrl = result.FinalUrl;
                    action = result.Action.ToString();
                    rewritePath = result.RewritePath;
                }
                //format up the error message to show
                const string debugMsg = "{0}, {1}, {2}, {3}, {4}, {5}, {6}";
                string productVer = DotNetNukeContext.Current.Application.Version.ToString();
                string portalSettings = "";
                string browser = "Unknown";
                //949 : don't rely on 'result' being non-null
                if (result != null)
                {
                    browser = result.BrowserType.ToString();
                }
                if (context.Items.Contains("PortalSettings"))
                {
                    var ps = (PortalSettings) context.Items["PortalSettings"];
                    if (ps != null)
                    {
                        portalSettings = ps.PortalId.ToString();
                        if (ps.PortalAlias != null)
                        {
                            portalSettings += ":" + ps.PortalAlias.HTTPAlias;
                        }
                    }
                }
                response.AppendHeader("X-" + _productName + "-Debug",
                                      string.Format(debugMsg, requestUri, finalUrl, rewritePath, action, productVer,
                                                    portalSettings, browser));
                int msgNum = 1;
                if (result != null)
                {
                    foreach (string msg in result.DebugMessages)
                    {
                        response.AppendHeader("X-" + _productName + "-Debug-" + msgNum.ToString("00"), msg);
                        msgNum++;
                    }
                }
                if (ex != null)
                {
                    response.AppendHeader("X-" + _productName + "-Ex", ex.Message);
                }
            }
        }
开发者ID:davidsports,项目名称:Dnn.Platform,代码行数:60,代码来源:AdvancedUrlRewriter.cs


示例7: CheckForRedirects

        private static bool CheckForRedirects(Uri requestUri, 
                                                string fullUrl, 
                                                NameValueCollection queryStringCol,
                                                UrlAction result, 
                                                string requestType, 
                                                FriendlyUrlSettings settings,
                                                int portalHomeTabId)
        {
            bool redirected = false;
            if (queryStringCol["error"] == null && queryStringCol["message"] == null && requestType != "POST")
            {
                //if the / is missing from an extension-less request, then check for a 301 redirect
                if (settings.PageExtensionUsageType == PageExtensionUsageType.Never)
                {
                    //575 check on absolutePath instead of absoluteUri : this ignores query strings and fragments like #
                    //610 don't always end with '/' - reverses previous setting
                    //687 don't double-check 301 redirects.  'CheckFor301' is less concise than 'Redirect301'
                    // DNN-21906: if the redirect is for splash page, then we should continue the 302 redirect.
                    if (requestUri.AbsolutePath.EndsWith("/") && result.Action != ActionType.Redirect301 && result.Reason != RedirectReason.Requested_SplashPage)
                    {
                        result.Action = ActionType.CheckFor301;
                    }
                }
                if (settings.RedirectWrongCase && result.Action == ActionType.Continue)
                {
                    result.Action = ActionType.CheckFor301;
                }
                string scheme = requestUri.Scheme + Uri.SchemeDelimiter;
                bool queryStringHas301Parm = (queryStringCol["do301"] != null);
                //727 : keep a bool value if there is a do301 request in the querystring
                //check for a 301 request in the query string, or an explicit 301 or 302 request
                //2.0 - check for explicit do301=true instead of just do301 key
                string do301Val = queryStringCol["do301"];
                if (result.TabId > -1 //valid tab
                    && (result.Action == ActionType.Redirect301 //specific 301 redirect
                        || (do301Val != null && do301Val == "true") //or rewrite hint for specific 301 redirect 
                        || result.Action == ActionType.Redirect302)) //or specific 302 redirect
                {
                    //we have ordered a 301 redirect earlier in the code
                    //get the url for redirection by re-submitting the path into the Friendly Url Provider
                    string pathOnly = RewriteController.GetRewriteOrRequestedPath(result, requestUri);
                    //727 prevent redirectLoop with do301 in querystring
                    if (result.Action == ActionType.Redirect301 || queryStringHas301Parm || result.Action == ActionType.Redirect302)
                    {
                        pathOnly = RedirectTokens.RemoveAnyRedirectTokens(pathOnly, queryStringCol);
                    }

                    //check for exclusion by regex for this url
                    if (result.RedirectAllowed)
                    {
                        //get the tab so we know where to go
                        TabInfo tab;
                        bool checkRedirect = CheckFor301RedirectExclusion(result.TabId, result.PortalId, true, out tab, settings);

                        if (checkRedirect)
                        {
                            if ((result.Reason == RedirectReason.Deleted_Page || result.Reason == RedirectReason.Disabled_Page)
                                && portalHomeTabId > 0
                                && settings.DeletedTabHandlingType == DeletedTabHandlingType.Do301RedirectToPortalHome)
                            {
                                //redirecting to home page  
                                TabInfo homeTab = TabController.Instance.GetTab(portalHomeTabId, result.PortalId, false);
                                if (homeTab != null)
                                {
                                    string homePageUrl = AdvancedFriendlyUrlProvider.ImprovedFriendlyUrl(homeTab, 
                                                                                                         pathOnly,
                                                                                                         Globals.glbDefaultPage,
                                                                                                         result.HttpAlias,
                                                                                                         false, 
                                                                                                         settings,
                                                                                                         Guid.Empty);
                                    result.Action = ActionType.Redirect301;
                                    result.FinalUrl = homePageUrl;
                                    result.RewritePath = pathOnly;
                                    redirected = true;
                                }
                            }
                            else
                            {
                                //get the rewrite or requested path in a clean format, suitable for input to the friendly url provider
                                string cleanPath = RewriteController.GetRewriteOrRequestedPath(result, requestUri);

                                //727 prevent redirectLoop with do301 in querystring
                                //also check for existing in path of do301 token
                                if (result.Action == ActionType.Redirect301 || do301Val != null || result.Action == ActionType.Redirect302)
                                {
                                    cleanPath = RedirectTokens.RemoveAnyRedirectTokens(cleanPath, queryStringCol);
                                }

                                //get best friendly url from friendly url provider
                                string bestFriendlyUrl = AdvancedFriendlyUrlProvider.ImprovedFriendlyUrl(tab, 
                                                                                                         cleanPath,
                                                                                                         Globals.glbDefaultPage,
                                                                                                         result.HttpAlias,
                                                                                                         false, 
                                                                                                         settings,
                                                                                                         Guid.Empty);

                                //get what the friendly Url for this tab should be and stick it in as the redirect
                                //727 : using boolean because we wanted to get rid of the do301 before calculating the correct url
//.........这里部分代码省略.........
开发者ID:davidsports,项目名称:Dnn.Platform,代码行数:101,代码来源:AdvancedUrlRewriter.cs


示例8: IgnoreRequest

 private static bool IgnoreRequest(UrlAction result, string requestedPath, string ignoreRegex, HttpRequest request)
 {
     bool retVal = false;
     //check if we are upgrading/installing 
     //829 : use result physical path instead of requset physical path
     //875 : cater for the upgradewizard.aspx Url that is new to DNN 6.1
     if (request != null && (IgnoreRequestForInstall(request) || IgnoreRequestForWebServer(requestedPath)))
     {
         //ignore all install requests
         retVal = true;
     }
     else if (request != null && (request.Path.EndsWith("SetGettingStartedPageAsShown") || request.Path.ToLower().EndsWith("ImageChallenge.captcha.aspx".ToLower())))
     {
         //ignore request to the Getting Started Web Method
         retVal = true;
     }
     else
     {
         try
         {
             if ((ignoreRegex.Length > 0))
             {
                 if (Regex.IsMatch(requestedPath, ignoreRegex, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
                 {
                     retVal = true;
                 }
             }
         }
         catch (Exception ex)
         {
             UrlRewriterUtils.LogExceptionInRequest(ex, "Not Set", result);
             result.Ex = ex;
         }
     }
     return retVal;
 }
开发者ID:davidsports,项目名称:Dnn.Platform,代码行数:36,代码来源:AdvancedUrlRewriter.cs


示例9: RewriteAsChildAliasRoot

 internal static void RewriteAsChildAliasRoot(HttpContext context, 
                                                 UrlAction result, 
                                                 string aliasQueryString,
                                                 FriendlyUrlSettings settings)
 {
     string culture = null;
     //look for specific alias to rewrite language parameter
     var primaryAliases = PortalAliasController.Instance.GetPortalAliasesByPortalId(result.PortalId).ToList();
     if (result.PortalId > -1 && result.HttpAlias != null)
     {
         culture = primaryAliases.GetCultureByPortalIdAndAlias(result.PortalId, result.HttpAlias);
     }
     if (string.IsNullOrEmpty(culture))
         //732 : when no culture returned can be "" as well as null : no culture causes no rewrite, which results in redirect to parent alias
     {
         //set the default culture code here
         //735 : switch to custom method for getting portal
         PortalInfo pi = CacheController.GetPortal(result.PortalId, false);
         if (pi != null)
         {
             culture = pi.DefaultLanguage;
         }
     }
     if (!string.IsNullOrEmpty(culture)) //a culture was identified for the alias root
     {
         if (RewriteController.AddLanguageCodeToRewritePath(ref aliasQueryString, culture))
         {
             result.CultureCode = culture;
         }
         result.DoRewrite = true;
         result.RewritePath = "~/" + Globals.glbDefaultPage + aliasQueryString;
         //the expected /default.aspx path (defaultPageUrl) matches the requested Url (/default.aspx)
         if (context != null)
         {
             //only do if not testing
             RewriterUtils.RewriteUrl(context, result.RewritePath);
         }
     }
 }
开发者ID:davidsports,项目名称:Dnn.Platform,代码行数:39,代码来源:AdvancedUrlRewriter.cs


示例10: 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


示例11: 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


示例12: IsRedirectAllowed

 private bool IsRedirectAllowed(string url, HttpApplication app, PortalSettings portalSettings)
 {
     var urlAction = new UrlAction(app.Request);
     urlAction.SetRedirectAllowed(url, new FriendlyUrlSettings(portalSettings.PortalId));
     return urlAction.RedirectAllowed;
 }
开发者ID:hungnt-me,项目名称:Dnn.Platform,代码行数:6,代码来源:MobileRedirectModule.cs


示例13: ShowDebugData

        private static void ShowDebugData(HttpContext context, string requestUri, UrlAction result, Exception ex)
        {
            if (context != null)
            {
                HttpResponse response = context.Response;

                //handle null responses wherever they might be found - this routine must be tolerant to all kinds of invalid inputs
                if (requestUri == null)
                {
                    requestUri = "null Uri";
                }
                string finalUrl = "null final Url";
                string rewritePath = "null rewrite path";
                string action = "null action";
                if (result != null)
                {
                    finalUrl = result.FinalUrl;
                    action = result.Action.ToString();
                    rewritePath = result.RewritePath;
                }
                //format up the error message to show
                const string debugMsg = "{0}, {1}, {2}, {3}, {4}, {5}, {6}";
                string productVer = Assembly.GetExecutingAssembly().GetName(false).Version.ToString();
                string portalSettings = "";
                string browser = "Unknown";
                //949 : don't rely on 'result' being non-null
                if (result != null)
                {
                    browser = result.BrowserType.ToString();
                }
                if (context.Items.Contains("PortalSettings"))
                {
                    var ps = (PortalSettings) context.Items["PortalSettings"];
                    if (ps != null)
                    {
                        portalSettings = ps.PortalId.ToString();
                        if (ps.PortalAlias != null)
                        {
                            portalSettings += ":" + ps.PortalAlias.HTTPAlias;
                        }
                    }
                }
                response.AppendHeader("X-" + _productName + "-Debug",
                                      string.Format(debugMsg, requestUri, finalUrl, rewritePath, action, productVer,
                                                    portalSettings, browser));
#if (DEBUG)
                var rawOutput = new StringWriter();
                rawOutput.WriteLine("<div style='background-color:black;color:white;'>");
                rawOutput.WriteLine("<p>Advanced Url Rewriting Debug Output</p>");
                rawOutput.WriteLine("<p>" +
                                    string.Format(debugMsg, requestUri, finalUrl, rewritePath, action, productVer,
                                                  portalSettings, browser) + "</p>");
#endif
                int msgNum = 1;
                if (result != null)
                {
                    foreach (string msg in result.DebugMessages)
                    {
#if (DEBUG)
                        rawOutput.WriteLine("<div>Debug Message " + msgNum.ToString("00") + ": " + msg + "</div>");
#endif
                        response.AppendHeader("X-" + _productName + "-Debug-" + msgNum.ToString("00"), msg);
                        msgNum++;
                    }
                }
                if (ex != null)
                {
                    response.AppendHeader("X-" + _productName + "-Ex", ex.Message);
                }
#if (DEBUG)
                if (ex != null)
                {
                    rawOutput.WriteLine("Exception : " + ex.Message);
                }
                else
                {
                    rawOutput.WriteLine("No Exception");
                }

                rawOutput.WriteLine("</div>");
                response.Write(rawOutput.ToString());
#endif
            }
        }
开发者ID:rut5949,项目名称:Dnn.Platform,代码行数:84,代码来源:AdvancedUrlRewriter.cs


示例14: SetRedirectReasonAndAction

 /// <summary>
 /// Sets the Action and Reason values in the UrlAction parameter
 /// </summary>
 /// <param name="result"></param>
 /// <param name="settings"></param>
 internal static void SetRedirectReasonAndAction(ref UrlAction result, FriendlyUrlSettings settings)
 {
     RedirectReason reason;
     ActionType action;
     string newUrl;
     DetermineRedirectReasonAndAction(result.RewritePath, result, true, settings, out newUrl, out reason,
                                      out action);
     result.Action = action;
     result.Reason = reason;
     result.RewritePath = newUrl;
 }
开发者ID:rut5949,项目名称:Dnn.Platform,代码行数:16,代码来源:RedirectTokens.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: CheckForRedirect

 internal static bool CheckForRedirect(Uri requestUri, 
                                         UrlAction result, 
                                         NameValueCollection queryStringCol,
                                         FriendlyUrlSettings settings, 
                                         out string location,
                                         ref List<string> messages, 
                                         Guid parentTraceId)
 {
     bool redirected = false;
     location = "";
     ExtensionUrlProvider activeProvider = null;
     try
     {
         List<ExtensionUrlProvider> providersToCall = GetProvidersToCall(result.TabId, result.PortalId, settings,
                                                                      parentTraceId);
         if (providersToCall != null && providersToCall.Count > 0)
         {
             FriendlyUrlOptions options = UrlRewriterUtils.GetOptionsFromSettings(settings);
             foreach (ExtensionUrlProvider provider in providersToCall)
             {
                 activeProvider = provider; //for error handling
                 redirected = provider.CheckForRedirect(result.TabId, result.PortalId, result.HttpAlias,
                                                        requestUri, queryStringCol, options, out location,
                                                        ref messages);
                 if (redirected)
                 {
                     result.FinalUrl = location;
                     result.Reason = RedirectReason.Module_Provider_Redirect;
                     break;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         //log module provider exception
         LogModuleProviderExceptionInRequest(ex, "500 Internal Server Error", activeProvider, result, messages);
         //return defaults
         redirected = false;
         location = "";
         string providerName = "Unknown";
         if (activeProvider != null)
         {
             providerName = activeProvider.ProviderConfig.ProviderName;
         }
         if (result != null)
         {
             result.DebugMessages.Add("Exception in provider [" + providerName + "] :" + ex.Message);
         }
     }
     return redirected;
 }
开发者ID:rrsc,项目名称:Dnn.Platform,代码行数:52,代码来源:ExtensionUrlProviderController.cs


示例17: CheckIfAliasIsC


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Users.UserInfo类代码示例发布时间:2022-05-24
下一篇:
C# Urls.FriendlyUrlSettings类代码示例发布时间: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