0

I have created an MVC web application.

I have a problem with @Html.ActionLink("Contact", "Contact", "Home").

I was expecting the link would take me to localhost:5123/Home/Contact.

Unfortunately it takes me to localhost:5123/?action=Contact&controller=Home

Any idea what I'm doing wrong?

It looks like all my Html.ActionLink are not working correctly.

1
  • 2
    Please post your RouteConfig and where your view resides within the project structure. Commented Apr 25, 2014 at 1:49

2 Answers 2

1

I think you need to do this:

@Html.ActionLink("Contact", "Home") 

Update

I presume you want this:

 @Html.ActionLink("Contact", "Contact", "Home", null, null) 

Source MSDN

Sign up to request clarification or add additional context in comments.

2 Comments

I guess his routing. But as he got different result that why I gave those both above
0

If your view chtml file (which you try to add the link) is not in the Home folder then you need to specify which controller you try to direct.

In best practise try add action link on following way.

@Html.ActionLink("Link name","Your Action Name", "Your Controller Name", new {Route paramters}, new {html attributes}) 

1 Comment

Hi Guys just a humble request if you mark minus can you please add a comment so then i can learn something and correct my self. Thank you very much

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.