I have the following folder structure
->People
-->Views
--->Reports
--->index.cshtml
---->PhoneCalls
----->Report.cshtml
-->Controlers
--->ReportsControler.cs
how do I navigate from index.cshtml to Report.cshtml using a @html.ActionLink
helper
I have tried
@Html.ActionLink("Report", "PhoneCalls/Report", null, new { target = "__blank" });
with fail.
I'm still not quite sure what your setup is, but for the general case of linking to a view that is included in a subfolder of the Views
folder.
Link to your controller action that handles the view, not the view itself
@Html.ActionLink("Report", "Report", "Reports", null, new { target = "_blank" });
First parameter is just the link text, followed by the action, then the controller (not the view), no route parameters, and your HTML attributes.
The Report
action on the Reports
controller is going to look for a Views/Reports/Report.cshtml
file. Since this does not exist, you can pass in a string parameter to the View()
method to specify which view you're actually using.
public ActionResult Report()
{
// Do your controller work
return View("PhoneCalls/Report");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With