user2043267
user2043267

Reputation: 71

Why doesnt my @html.actionlink go to the correct link?

Im having a problem with going to the correct link. When im trying to go to index view in template folder it goes to index view in admin folder instead and i cant understand why when the code says it should look for this view in this specific folder:

<fieldset>

<legend>SiteConfig</legend>
<p>Create new or edit Customers, Projects etc:   
    @Html.ActionLink("Create", "Add", "Admin", string.Empty) |
    @Html.ActionLink("Edit", "AddEdit", "Admin", string.Empty)
</p>
<p>Create new or edit Users:
    @Html.ActionLink("Create", "Add", "Admin", string.Empty) |
    @Html.ActionLink("Edit", "AddEdit", "Admin", string.Empty)
</p>
<p>Upload or change Logo:
    @Html.ActionLink("Upload", "Add", "Admin", string.Empty) |
    @Html.ActionLink("Change", "AddEdit", "Admin", string.Empty)
</p>
<p>Upload or change Template:
    @Html.ActionLink("Upload", "Index", "Template", string.Empty) |
    @Html.ActionLink("Change", "AddEdit", "Admin", string.Empty)
</p>
</fieldset>

Upvotes: 0

Views: 206

Answers (2)

von v.
von v.

Reputation: 17118

You are most probably calling the wrong overload. What is that string.Empty for?

Is Admin a controller and if so then you can just simple do a

@Html.ActionLink("Create", "Add", "Admin") 

Are you trying to add some html styling to your links, then do this

@Html.ActionLink("Create", "Add", "Admin", new { @class = "some-class-name"} ) 

Are you trying to pass some parameters

@Html.ActionLink("Create", "Add", "Admin", new { @id = 5}, null ) 

Upvotes: 1

Andras Toth
Andras Toth

Reputation: 628

Your question isn't completely clear, but for the links you provided, always Admin is set as a controller name (third parameter). So in all of your links, the Add or AddEdit method will be called in the Admin controller, and therefore always the Add or AddEdit template will be used from the Views/Admin folder.

Upvotes: 0

Related Questions