Q: Asp.NET MVC3 Bad Request It's my first project in ASP.NET MVC (MVC3) and I'm having a lot of trouble dealing with everything. All my text in the pages will be selected from database, according to language selected. For this language selection I preferred to use a Session variable. I need an Image Link to languages so I wrote the following lines into .cshtml page.
@using (Html.BeginForm()) {
    <a href='<%: Url.Action("Index", "Home", new { lang="Tr" }) %>'>
        <img src="../../Content/Images/flag_tr.jpg" width="40" height="20" />
    </a>
    <a href='<%: Url.Action("Index", "Home", new { lang = "En" }) %>'>
        <img src="../../Content/Images/flag_en.jpg" width="40" height="20" />
    </a>
}

And in the HomeController:
    public ActionResult Index()

        ViewBag.Message = "Welcome to ASP.NET MVC!";
        ViewBag.Selected = "Not yet selected";
        return View();
    }

    [HttpPost]
    public ActionResult Index(String lang)
    {
        if (lang == "Tr")
        {
            System.Web.HttpContext.Current.Session["Language"] = "Tr";
        }
        else if (lang == "En")
        {
            System.Web.HttpContext.Current.Session["Language"] = "En";
        }
        ViewBag.Selected = System.Web.HttpContext.Current.Session["Language"];
        return View();
    }

When I click on a flag link I get "HTTP Error 400 - Bad Request." Can anybody tell me what I'm doing wrong, or what I should do?
P.S.: I have also tried without Form, adding a new function into Controller named Lang and redirect from there to Index, but no success.

A: You appear to be mixing Razor and WebForms syntax. When you "view source" on your page, I am sure you will not see a correct URL in your anchors:
<a href='<%: Url.Action("Index", "Home", new { lang="Tr" }) %>'>

should be:
<a href='@Url.Action("Index", "Home", new { lang="Tr" })'>

Also, note that anchors cause an HTTPGET, even in a form, so you would need to override their behavior with JavaScript or add your lang checks to the HTTPGET version of your controller action. Try something like this, combining your two controller actions into one:
public ActionResult Index(string lang)
{
    if (lang == "Tr")
    {
        System.Web.HttpContext.Current.Session["Language"] = "Tr";
    }
    else if (lang == "En")
    {
        System.Web.HttpContext.Current.Session["Language"] = "En";
    }

    ViewBag.Message = "Welcome to ASP.NET MVC!";
    ViewBag.Selected = System.Web.HttpContext.Current.Session["Language"] ?? "Not yet selected";
    return View();
}

If you don't decorate this with [HttpGet] or [HttpPost], then any HTTP verb will be mapped to this action.

A: If I am not wrong your HomeController class name is HomeController.
<a href='<%: Url.Action("Index", "HomeController", new { lang="Tr" }) %>'>
    <img src="../../Content/Images/flag_tr.jpg" width="40" height="20" />
</a>

So when you are specifying the Controller in Url.Action, it should only be Home and not HomeController.
So your code in view will be like below:
@using (Html.BeginForm()) {
    <a href='<%: Url.Action("Index", "Home", new { lang="Tr" }) %>'>
        <img src="../../Content/Images/flag_tr.jpg" width="40" height="20" />
    </a>
    <a href='<%: Url.Action("Index", "Home", new { lang = "En" }) %>'>
        <img src="../../Content/Images/flag_en.jpg" width="40" height="20" />
    </a>
}

Let me know if this works for you or you need more clarification. Thanks
