Click here to Skip to main content
15,867,778 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have made a website in which i have used URL Re Writing.

through which i changed my original url http://www.mywebsite.com/tender.aspx to http://www.mywebsite.com/onlinetenders


i have implemented it in Global.asax file in Application_BeginRequest function.

it is working fine when i upload website at root domain of my website which is http://www.mywebsite.com but when i create virtual folder named en for enlish version. so that i can run multiple versions in single domain setup then it is creating problem. and script url and css link url is rendering correct path. modfied path should start from http://www.mywebsite.com/en/ for all links as i have created web application under new virtual folder. but it is still taking path from root website http://www.mywebsite.com. after that, content of that page is not showing properly.

I want to know how to make content page relative to physical path of page not with re write path.

I may have choosen the way of routing or another rewrite module. but i have to make rewriting work in Global.asax in Application_BeginRequest function because i am making url dynamic for CMS application.


Improtant :- Please do not be confused with en as culture, i am taking it as sub domain so that string can be changed. and new sub domain path can be anything like http://www.mywebsite.com/onlineapp.


HttpContext InRequest = HttpContext.Current;

string path = InRequest.Request.Path;

C#
if (path.ToUpper().Contains("/onlinetenders") == true)
        {
            path = "frmTenderDetails.aspx";
            if (InRequest.Request.QueryString.Count != 0)
            {
                string sign = (path.IndexOf('?') == -1) ? "?" : "&";
                path = path + sign + InRequest.Request.QueryString.ToString();
            }
            else
            {
                path = path + "?cd=" + InRequest.Server.UrlEncode(db.EncodeTo64("0"));
            }

            string rew = "~/" + path;

            InRequest.Items.Add(
                "OriginalUrl",
                HttpContext.Current.Request.RawUrl);

            string baseUrl = "~/frmTenderDetails.aspx?";

            string qrstr = rew.Substring(baseUrl.Length, rew.Length - baseUrl.Length);

            InRequest.RewritePath(baseUrl.Substring(0, baseUrl.Length - 1), "", qrstr, true);

            //InRequest.RewritePath("~/frmTenderDetails.aspx", "", "", true);
        }
Posted
Updated 5-Jul-15 18:59pm
v6
Comments
Kornfeld Eliyahu Peter 22-Jun-15 5:33am    
Please show the part of the URL rewriting of your code...
Gaurav Gupta A Tech Guy 26-Jun-15 1:46am    
Please help me ?
CHill60 22-Jun-15 8:25am    
When you post the URL rewriting of your code use the Improve question link and also change the all-capitals in you title to mixed-case. All capitals is considered shouting and rude, so fewer people will be inclined to read your question and help
Gaurav Gupta A Tech Guy 26-Jun-15 1:43am    
Please help me ?
CHill60 27-Jun-15 6:47am    
This is not my area of expertise - I was only helping you to change your question to make sure more people would look at it.
I suggest trying to think of anything else you can add to the information and edit your question again - it will move back to the front of the list which might help an expert spot it. Don't do that too often though or it will annoy members

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