We help IT Professionals succeed at work.

Problems with MasterPage after using method HttpContext.Current.RewritePath(); C#.NET

nick_humlessen
on
1,114 Views
Last Modified: 2008-01-09
I'm using my method URL_FILTER(Uri uri) to rewrite some Paths but some images on MasterPage just can not get ImageUrl
after rewriting path. What should I do?
  public static void URL_FILTER(Uri uri)
    {
       
        string[] splitter = new string[1];
        splitter[0] = @"/";
        //if (uri.PathAndQuery == @"/PRCDATA/Sub_Forside.aspx")
        //    HttpContext.Current.RewritePath("~/Forside1.aspx");
        string str_url = uri.PathAndQuery;
        string[] aliaces = str_url.Split(splitter, System.StringSplitOptions.None);
        int count = 0;
        for (int i = 0; i < aliaces.Length; i++)
        {
            if (aliaces[i] != null)
                count++;
        }

        if (aliaces[2] == "Products")
        {
            if (count == 4 && aliaces[3] != "Forside1.aspx" && aliaces[3] != "Sub_Forside.aspx" && aliaces[3] != "Sub_Sub_Forside.aspx" && aliaces[3] != "Product_List.aspx" && aliaces[3] != "ShowHardware.aspx" && aliaces[3] != "Kurv.aspx" && aliaces[3] != "TomKurv.aspx")
            {
                HttpContext.Current.RewritePath("/PRCDATA/Products/Sub_Forside.aspx");
            }
            if (count == 5 && aliaces[4] != "Sub_Sub_Forside.aspx" && aliaces[3] != "Images")
            {
                HttpContext.Current.RewritePath("/PRCDATA/Products/Sub_Sub_Forside.aspx");
            }
            if (count == 5 && aliaces[4] == "Sub_Sub_Forside.aspx")
                HttpContext.Current.RewritePath("/PRCDATA/Products/Sub_Sub_Forside.aspx");
            if (count == 6 && aliaces[4] != "Sub_Sub_Forside.aspx" && aliaces[3] != "Images" && aliaces[3] != "images" && aliaces[4] != "images" && aliaces[4] != "Images" && aliaces[3] != "App_Themes" && aliaces[5] != "Product_List.aspx")
                HttpContext.Current.RewritePath("/PRCDATA/Products/Product_List.aspx");
            if (count == 6 && aliaces[5] == "Product_List.aspx")
                HttpContext.Current.RewritePath("/PRCDATA/Products/Product_List.aspx");
            if (count == 7 && aliaces[4] != "Sub_Sub_Forside.aspx" && aliaces[3] != "Images" && aliaces[3] != "images" && aliaces[4] != "images" && aliaces[4] != "Images" && aliaces[5] != "images" && aliaces[5] != "Images" && aliaces[3] != "App_Themes" && aliaces[4] != "App_Themes" && aliaces[5] != "Product_List.aspx")
                HttpContext.Current.RewritePath("/PRCADATA/Products/ShowHardware.aspx");

        }
    }
Comment
Watch Question

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
I'v forgot that I should use AbsolutUri address  for Images, sometimes when tired we do so stupid mistakes.
Sorry for stupid question. Thanks whatever.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.