@Url.Action not working???

Hi Guys,

   I want to navigate to another controller when user click on button, so i using @Url.Action but its not working properly, below you can see my code.

  <button type="button" value="Save1" onclick="location.href='@Url.Action("Index", "PatientDetails")'" /> and i  also tried with

  <input type="button" value="Save" onclick="location.href='@Url.Action("Index", "PatientDetails")'"/>

 but i get this error

    IIS 10.0 Detailed Error - 404.0 - Not Found

    HTTP Error 404.0 - Not Found

    The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
  here i have patientdetails controlller
  
PatientDetails:-
public class PatientDetailsController : PageController<PatientDetails>
{
     public ActionResult Index(PatientDetails currentPage)
     {

      return View(currentPage);
    }
}
Inddex.cshtml:-
@model EpiRegistration.Models.Pages.PatientDetails

@{
      ViewBag.Title = "Index";
   }

<h2>This Patient Details Page</h2>
    Please can anyone help me out of this.
Thanks,
Kartheek
#180434 Jul 10, 2017 14:12
  • Member since: 2007

    Hi,

    If you just render @Url.Action("Index", "PatientDetails"), what do you end up with then? Also, you shouldn't use a button for navigation, you must use a regular link (a/anchor tag).

    If you want to generate a link to public ActionResult Index(PatientDetails currentPage) you should do like this: @Url.Action("Index", new { node = Model.ContentLink }). Episerver is using 'node' internally to route to an action with PageData.

    #180437 Jul 10, 2017 15:57