Subject. My code

public ActionResult Index() { if (Request.UserLanguages.Count() != 0 & Request.UserLanguages.Contains("ru-RU")) return View("Ru"); return View(); } 

Ru view exists in the same folder as Index

  • and if you register the full path? return View ("~ / Views / ___ / ru.cshtml"); - Ruslan_K
  • A view with the specified name is searched in the following places: Views / Controller / ViewName or Views / Shared / ViewName - Bald

1 answer 1

The path to this view will look like / {controller} / {action}, Ie in your case, localhost: port / controller / Index , and only then will the search for the "Ru.cshtml" view be made.

The route refers to the action method, not the file.

You can add your route to RouteConfig:

 routes.MapRoute( name: "MyPath", url: "{controller}/RU", defaults: new { controller = "Ваш_контроллер", action = "Index", id = UrlParameter.Optional } ); 
  • You can specify the name of a specific view, but it should be accessible via one of the Views / Controller / ViewName paths or Views / Shared / ViewName - Bald