Пример #1
0
        static public string BuildInternalURL(URLContext urlContext)
        {
            string url = null;

            if (urlContext.Virtual != null)
            {
                url = "/" + urlContext.Virtual;
            }
            if (urlContext.Resource != null)
            {
                url = url + urlContext.Resource;
            }
            else if (urlContext.Section == null)
            {
                url = url + "/pages/Default.aspx";
            }
            else
            {
                if (urlContext.Topic == null)
                {
                    url = url + "/pages/Default.aspx";
                }
                else
                {
                    bool fileExist = false;
                    if (!("topic".Equals(urlContext.Section)))
                    {
                        if (!ContainsSpecialCaracters(urlContext.Topic))
                        {
                            string relativePath = "~/pages/" + urlContext.Section + "/" + urlContext.Topic + ".aspx";
                            string filepath = System.Web.Hosting.HostingEnvironment.MapPath(relativePath);
                            if (File.Exists(filepath))
                            {
                                url = url + "/pages/" + urlContext.Section + "/" + urlContext.Topic + ".aspx";
                                fileExist = true;
                            }
                        }
                    }
                    if (!fileExist)
                    {
                        url = url + "/pages/" + urlContext.Section + "/Default.aspx?topic=" + HttpUtility.UrlEncode(urlContext.Topic);
                        if (urlContext.Page != null)
                        {
                            url = url + "&page=" + urlContext.Page; ;
                        }
                    }
                }
            }

            return url;
        }
Пример #2
0
 static public void StoreURLContext(URLContext urlContext)
 {
     HttpContext.Current.Items.Add("context", urlContext);
 }