Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am using visual studio 2010 for a urlrewriting with httpmodule.
The code which I am using just like below

C#
HttpApplication MyApp =(HttpApplication) sender;
            string MyOldPath = MyApp.Request.Path;
            string OriginalURL = string.Empty;
            switch (MyOldPath.ToLower())
            {
                case "/home":
                    OriginalURL = "Modules/Users/Home.aspx";
                     break;

                case "/library/getbook":
                     OriginalURL = "Modules/Books/BookShelf.aspx";
                     break;

                default:
                     break;
            }
            if (OriginalURL!=string.Empty)
                MyApp.Context.RewritePath(OriginalURL);
            string strURL= MyApp.Request.Url.ToString();



First case is working. But in the case of second case the url is rewritten by an additional "Library" root with the existing one. That is when hit the case "/library/getbook" the url will be Library/Modules/Books/BookShelf.aspx. Could you please help me to rewrite the root too.
Posted
Comments
Arkadeep De 20-Apr-15 6:33am    
Write original url as
OriginalURL = "~/Modules/Books/BookShelf.aspx";
give it a try..
Libin C Jacob 21-Apr-15 2:25am    
Thanks Arkadeep. Its working
Arkadeep De 21-Apr-15 2:34am    
you welcome...
Libin C Jacob 28-Apr-15 1:55am    
:)
Style-7 20-Apr-15 6:37am    
Try to use "/" before, so OriginalURL = "/Modules/Books/BookShelf.aspx";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900