Reputation: 69
I'm jumping to asp.net core. I have experience working with MVC framework.
When i set a URL.Action("Index", "Home") in a javascript variable the result is: "/Home/Index/" in mvc 4,
but in ASP.NET Core i try to do exactly the same, but what i only get is a slash printed "/"
what's wrong? I have read other questions, but no one can give a right answer.
<input type="hidden" value="@Url.Action("Index", "Home")" id="urlIndex" />
result:
<input type="hidden" value="/" id="urlIndex" />
Upvotes: 0
Views: 1305
Reputation: 29976
As @Stephen Muecke points out, this is by design.
If you need to generate /Home/Index
by @Url.Action("Index", "Home")
, try to add Route
on /Home/Index
for a workaround.
public class HomeController : Controller
{
[Route("/")]
[Route("/Home/Index")]
public IActionResult Index()
{
return View();
}
Upvotes: 1