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;
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);
}