I'm working on a multi language web site and I need to set language first and then shows the page in that exact language using Resources files.
I used two index action like this :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Mvc;
using System.Globalization;
using global_vrf.GeoIpService;
namespace global_vrf.Controllers
{
public class HomeController : Controller
{
public ActionResult Index(string language)
{
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(language);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(language);
return View();
}
public ActionResult Index()
{
string language="en-us";
return View(language);
}
}
}
but when I run the page, I have this Error:
The current request for action 'Index' on controller type 'HomeController' is ambiguous between the following action methods: System.Web.Mvc.ActionResult Index(System.String) on type global_vrf.Controllers.HomeController System.Web.Mvc.ActionResult Index() on type global_vrf.Controllers.HomeController
language
isnull
, the set it to"en-us"
– user3559349