asp.net(C#)2.0 开发webform 现在想要实现三级域名的转换,如:
http://www.honghai56.com/b2b/Default.aspx?username=hhwl
转换成 http://hhwl.b2b.honghai56.com 我的方法是这样的:
1、先将 *.honghai56.com, 全部指向 www.honghai56.com
2、然后在首页中判断,代码如下:
protected void Page_Load(object sender, EventArgs e)
{
//域名名转换
string url = this.Request.Url.ToString();//取得当前的网址
if (url.Contains(".b2b.honghai56.com"))
{
int i = url.LastIndexOf("/");
int j = url.IndexOf(".");
string urlname = url.Substring(i + 1, j - i - 1);
string urlnew = "http://www.honghai56.com/b2b/Default.aspx?username=" + urlname;
Response.Redirect(urlnew); //问题:用了这句代码后,显示的网址不再是三级域名了,如何让这个三级域名保持不变?
}
} 请指点一下,谢谢!!
http://www.honghai56.com/b2b/Default.aspx?username=hhwl
转换成 http://hhwl.b2b.honghai56.com 我的方法是这样的:
1、先将 *.honghai56.com, 全部指向 www.honghai56.com
2、然后在首页中判断,代码如下:
protected void Page_Load(object sender, EventArgs e)
{
//域名名转换
string url = this.Request.Url.ToString();//取得当前的网址
if (url.Contains(".b2b.honghai56.com"))
{
int i = url.LastIndexOf("/");
int j = url.IndexOf(".");
string urlname = url.Substring(i + 1, j - i - 1);
string urlnew = "http://www.honghai56.com/b2b/Default.aspx?username=" + urlname;
Response.Redirect(urlnew); //问题:用了这句代码后,显示的网址不再是三级域名了,如何让这个三级域名保持不变?
}
} 请指点一下,谢谢!!
或者:
Sever.Transfer(urlnew)这样可以。不过执行之后的网页连接依然是三级域名形式。