好的,這裏是...您可以獲取用戶的IP地址,並根據他/她的國家/地區將用戶重定向到特定的網頁。現在,你如何動態改變主頁面?這是怎麼了將用戶重定向: -初學ASP.NET C#關於動態更改母版頁的問題
Geolocation error with IP address 127.0.0.1
它不象用戶點擊一些按鈕或東西,然後你改變了母版頁。我希望在用戶重定向時更改它,那麼我該如何去做呢?
public partial class testClass: System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (redirected to site1)
{
Use this master page1
}
else
if (redirected to site2)
{
Use this master page2
}
}
}
那麼,如何檢查用戶被重定向到的SITE?現在如何應用特定的母版頁,現在用戶已被重定向?
我只是需要一個想法如何去做。
[編輯]請檢查下面的代碼塊。如何獲取用戶重定向到的URL?實際上我只需要「iso3166TwoLetterCode」變量的值(請參閱我之前問題的鏈接),並基於此將更改母版頁。我無法弄清楚如何獲取這個值,或者甚至在我的testClass中使用那個類(有這個變量)。
protected void Page_PreInit(object sender, EventArgs e)
{
if (user Has been redirected to www.site.in)
{
this.MasterPageFile = "master1.master";
}
if (user Has been redirected to www.site.fr)
{
this.MasterPageFile = "master2.master";
}
}
你能否檢查我剛添加的附加細節? thnx – Serenity 2010-09-11 11:13:56
我以爲你已經實現了這一點。 – Philipp 2010-09-11 12:03:30
想出瞭如何從URL.got幫助這裏獲取代碼http://stackoverflow.com/questions/3698196/how-do-i-check-for-a--a-urls-top-level-domain-in- ASP-網-C – Serenity 2010-09-17 07:10:10