Html.ActionLink sometimes doesn't redirect to the expected path

79 Views Asked by At

I have the following button on my website

@Html.ActionLink("Stock Manager", "Index", "StockManager",
 new { area = "Home" }, new { @class = "logo-stock-manager", @style = "float:left;" })

With the following method in the StockManagerController

public ActionResult Index()
{
     return View();
}

Some people that use my website have reported that when they're on localhost/Home/Quiosk/Index and click the button I mentioned they get redirected to localhost without any additional path instead of localhost/Home/StockManager/Index, they said that cleaning the browser data fixed it but sometimes it starts happening again.

I haven't had this problem in development or testing so I've never been able to debug it.

I release updates for my website every other week but I haven't changed these buttons in a while so I don't understand how cached data could be the problem. Is there a better approach to what I'm currrently doing? Using something different than ActionLink maybe ?

1

There are 1 best solutions below

0
Nightmare On

When you use the 'Html.ActionLink' in .NET MVC to create a link to another view within the same application, it will generate a URL based on the routing configuration of yout application. If the URl generated by the link redirects to 'localhost' only, it is likely due to:

  1. Incorrect Routing
  2. Incorrect method parameters on 'Html.ActionLink'
  3. Bad SSL Configuration (if is the case)
  4. Incorrectly specified path on route configuration

Check these 4 points, probably is one of them