5

I've got a simple view that creates a link if a login is successful and is located under /Login:

<div>
@Html.ActionLink("Add a new Organization", "AddOrganization", 
           "/Setup/AddOrganizationController", new { id = Session["ID"] }, null)
</div>

After reading other similiar problems, I tried it adding the null after, as well as a few other overloads, but I can't get the link to work right. When I click the link, it takes me to

http://setup/AddOrganizationController/AddOrganization

Which is leaving out the localhost part that needs to be there. Without the null at the end, it tries to send me to

/Login/AddOrganization

All I want is a link that will run an action within the AddOrganizationController controller which is under /Setup directory. The link should also pass the session id to the controller as an argument. How can I do this?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
SantasNotReal
  • 1,273
  • 6
  • 18
  • 25
  • I really don't know what that is, so I guess I'm not. – SantasNotReal Jul 12 '13 at 23:26
  • I can't really answer your question, don't even know the structure of your project but I guess it's worth you take a look at them. Maybe this answer helps you http://stackoverflow.com/a/6555971/1179061 – mitomed Jul 12 '13 at 23:29

1 Answers1

6

If it's in the same Area then you can just do:

@Html.ActionLink("Add a new Organization", "AddOrganization", "Organizations", new { id = Session["ID"] })

where "Organizations" is the controller name.

Otherwise, if it's in another area you would do something like

@Html.ActionLink("Add a new Organization", "AddOrganization", "Organizations", new { area = "areaName", id = Session["ID"] }, null)
Matt Millican
  • 4,044
  • 4
  • 38
  • 55