Exemplo n.º 1
0
        /// <summary>
        ///   Gets the permanent URL for the <see cref="WxeFunction"/> of the specified <paramref name="functionType"/>
        ///   and using the <paramref name="urlParameters"/>.
        /// </summary>
        /// <include file='..\doc\include\ExecutionEngine\WxeContext.xml' path='WxeContext/GetPermanentUrl/param[@name="functionType" or @name="urlParameters" or @name="useParentPermanentUrl"]' />
        public string GetPermanentUrl(Type functionType, NameValueCollection urlParameters, bool useParentPermanentUrl)
        {
            ArgumentUtility.CheckNotNull("urlParameters", urlParameters);

            string permanentUrl = WxeContext.GetPermanentUrl(_httpContext, functionType, urlParameters, true);

            if (useParentPermanentUrl)
            {
                if (urlParameters[WxeHandler.Parameters.ReturnUrl] != null)
                {
                    throw new ArgumentException("The 'urlParameters' collection must not contain a 'ReturnUrl' parameter when creating a parent permanent URL.", "urlParameters");
                }

                int maxLength = Configuration.WebConfiguration.Current.ExecutionEngine.MaximumUrlLength;

                string           currentFunctionUrl  = UrlUtility.AddParameters(_httpContext.Request.Url.AbsolutePath, _queryString, _httpContext.Response.ContentEncoding);
                StringCollection parentPermanentUrls = ExtractReturnUrls(currentFunctionUrl);

                int    count = GetMergeablePermanentUrlCount(permanentUrl, parentPermanentUrls, maxLength);
                string parentPermanentUrl = FormatParentPermanentUrl(parentPermanentUrls, count);

                if (!string.IsNullOrEmpty(parentPermanentUrl))
                {
                    permanentUrl = UrlUtility.AddParameter(permanentUrl, WxeHandler.Parameters.ReturnUrl, parentPermanentUrl, _httpContext.Response.ContentEncoding);
                }
            }
            return(permanentUrl);
        }
Exemplo n.º 2
0
        private static string GetExternalFunctionUrl(WxeFunction function, bool createPermaUrl, NameValueCollection urlParameters)
        {
            string functionToken = WxeContext.Current.GetFunctionTokenForExternalFunction(function, false);

            NameValueCollection internalUrlParameters;

            if (urlParameters == null)
            {
                if (createPermaUrl)
                {
                    internalUrlParameters = function.VariablesContainer.SerializeParametersForQueryString();
                }
                else
                {
                    internalUrlParameters = new NameValueCollection();
                }
            }
            else
            {
                internalUrlParameters = NameValueCollectionUtility.Clone(urlParameters);
            }
            internalUrlParameters.Set(WxeHandler.Parameters.WxeFunctionToken, functionToken);
            return(WxeContext.GetPermanentUrl(WxeContext.Current.HttpContext, function.GetType(), internalUrlParameters));
        }