当前位置: 首页>>代码示例>>C#>>正文


C# UrlAction.SetRedirectAllowed方法代码示例

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


在下文中一共展示了UrlAction.SetRedirectAllowed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

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

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


注:本文中的DotNetNuke.Entities.Urls.UrlAction.SetRedirectAllowed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。