Reputation: 57
So i have 2 controller in my controller folder, BookController and HomeController. I am trying to make a header and call it with partial call so i don't have to create it multiple time.
I made my header like this
<div id ="header">
<img src="Images/logo.png" id="logo" />
<div class="navbar">@Html.ActionLink("Home","index")</div>
<div class="navbar">@Html.ActionLink("Loan","index","LoanController")</div>
<div class="navbar">Student</div>
<div class="navbar">Book</div>
when i am click it home it can bring me to the main page, but when i am click loan i got error "Server Error in '/' Application". I have try to change the loan controller with "~/LoanController" and "~/Controller/LoanController" but i keep got the same error. Can somebody help me solve this?
Upvotes: 0
Views: 224
Reputation: 5762
You don't need the "Controller" part of the Loan. ASP.NET MVC does that for you.
<div class="navbar">@Html.ActionLink("Loan","index","Loan")</div>
Edit: Behind the scenes MVC will look inside your Controllers Folder (which is the default folder for controllers) to a file that starts with "Loan".
In your case, you are using this overload of ActionLink:
LinkExtensions.ActionLink Method (HtmlHelper, String, String, String)
In which takes a controller name as the last parameter.
Upvotes: 1