ASP.Net MVC Keeping parameter names and action argument names in sync

ASP.Net MVC Keeping parameter names and action argument names in sync

I've noticed a pattern that can make refactoring MVC2 apps difficult. When you change the name of an argument for an action you must update the values everywhere that action is used. For example,

public ActionResult List(string p) 

in the view

<%= Html.ActionLink("List", "Directory", new { p = "somePath" }, null) %> 

What if I want to change p to be more descriptive such as path.

public ActionResult List(string path) 

This will mean that everywhere in the view where I've specified p = "somePath" it must be changed to path = "somePath". I see this as being tedious to track and maintain.

A static analysis of this seems to be the right solution for keeping arguments and parameters consistent. I know resharper has an indication if an action or view doesn't exist. I imagine it could just as easily detect parameter naming conflicts.

Ext.JS Store Record is undefined


How Many Times Does an ASP .NET Application Start
You could use the Lambda version of ActionLink. AJAX Call using jquery in mvc
 <% Html.ActionLink<HomeController>(a => a.Index(), "Home");  %> 
which will commit you compile time checking and strong typing.. Javascript not enabled
deploying MVC 1.0 app with HTTPSUsing System.ComponentModel.DisplayName with dynamic values?


Strongly typed user control model binding not working in Asp.Net MVC 2.0
You must use the T4MVC to generate strongly typed references to things this are normally represented as strings in regular MVC, for example:. MVC2 Partial View throws/catches exceptions while resolving the path to the view
<% Html.ActionLink("List", MVC.Home.Directory("any Path")) %> 
You must read more around T4MVC and download it from here:

41 out of 100 based on 41 user ratings 521 reviews