public partial class ChangeCulture : MyWebApplication.LocalizedPage
{
    protected void Page_Load(object sender, System.EventArgs e)
    {
      

        string strCulture = Request.Params["Culture"];
        if (string.IsNullOrEmpty(strCulture))
        {
            Response.Redirect("~/Default.aspx", false);
            return;
        }

        string strReferer = Request.ServerVariables["HTTP_REFERER"];
        if (string.IsNullOrEmpty(strReferer))
        {
            Response.Redirect("~/Default.aspx", false);
            return;
        }

        switch (strCulture.ToUpper())
        {
            case "FA-IR":
            case "EN-US":
                {
                    strCulture =
                        strCulture.Substring(0, 2).ToLower() +
                        "-" +
                        strCulture.Substring(3, 2).ToUpper();

                    Session["Culture"] = strCulture;

                    Response.Redirect(strReferer, false);
                    return;
                }

            default:
                {
                    Response.Redirect("~/Default.aspx", false);
                    return;
                }
        }
    }
}
