I've inherited a kludgy and buggy MVC code base from another developer, and I'm trying to clean it up. One thing that would be very helpful would be a tool to check, at compile time, for links that don't correspond to action methods in a controller.
For instance, you can write an action method like this:
public ActionResult InsertAccount(string Name)
and there could be a link somewhere that looks like this:
/SomeController/InsertAccount?Id=Foo
Somewhere along the way, the parameter got changed from "Id" to "Name", and this breaks the link. If everything were in C#, the compiler would catch it, but because the link is generated from strings, a change like this can't be detected.
Is there any tool that would do this, or guidelines for link construction to preserve name safety, so I can use the compiler to catch this kind of problem?
Check out T4MVC
With it you can write this:
@Html.ActionLink("Insert Account", MVC.SomeController.InsertAccount("Foo"))
You still will not get a compilation error when you build since Views are not compiled by default. however, you can change this in the project file as shown here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With