Strongly typed MVC action links
suggest changeInstead of the usual loosely typed:
@Html.ActionLink("Log in", "UserController", "LogIn")
A custom helper can make action links strongly typed. Stock Html.ActionLink has no overload that takes a Type and a method name:
@Html.ActionLink("Log in", @typeof(UserController), @nameof(UserController.LogIn))
Now if you want to refactor your code and rename the UserController.LogIn method to UserController.SignIn, you don’t need to worry about searching for all string occurrences. The compiler will do the job.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents