Razor view syntax question

Posted on 2011-09-22
Last Modified: 2012-05-12
The following syntax Razor View I

@ Html.ActionLink (item.Name, "Detail", "Restaurant", new {id = item.ID})

which implies the generation of the following link wrong:

If I add a null parameter as follows
@ Html.ActionLink (item.Name, "Detail", "Restaurant", new {id = item.ID}, null)
the link is correct

I want to know why you need to pass the parameter to null, and what it means
Question by:vgruppo
  • 2
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 36579433
public static string ActionLink(this HtmlHelper htmlHelper,  string linkText,  string actionName,                                string controllerName, object values, object htmlAttributes)

The parameter you meant is htmlattributes where as it used to pass any HTML attribute to the action link.

Please refer:


Accepted Solution

jagrut_patel earned 500 total points
ID: 36579488

Expert Comment

ID: 36579505
It calls this overload of ActionLink

By passing null value for 5th argument we make it invoke following overloaded method

Author Closing Comment

ID: 36579621
I would have preferred an explanation of the behavior of the function with 4 parameters and a few more example.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Definitions and default visual studio colors 5 58
Windows 10 IIS and Windows Authentication to SQL 21 52
Problem to error 4 43
Why is some text in blue in Visual Studio? 6 22
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now