Beginner ASP.NET C# question about dynamically changing master pages
<p>OK, here's the thing... You fetch the user's IP address and based on his/her country you redirect the user to a specific webpage. Now, how do you change the master page dynamically? This is how I am redirecting the user :-</p>

<p><a href="http://stackoverflow.com/questions/3690278/fetching-ip-address-and-displaying-country-in-c-and-asp-net">Geolocation Error with IP Address 127.0.0.1</a></p>

<p>It's not like the user clicks some button or something and you then change the master page. I want it changed when the user is redirected, so how exactly do I go about it?</p>

<pre><code>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
            }
    }
}
</code></pre>

<p>So how do I check what SITE the user has been redirected to? Also HOW to apply the specific master page now that the user has been redirected?</p>

<p>I just need an idea how to go about it.</p>

<p><strong>[EDIT] please check the code block below. How do I fetch the URL that the user has been redirected to? I actually need just the "iso3166TwoLetterCode" variable's value (see the link to my earlier question, please)  and based on that will be changing the master page. I can't figure out how to fetch that value or even use that class (that's got this variable) in my testClass</strong>.</p>

<pre><code>    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";
        }
    }
</code></pre>
