ZZZ
ZZZ

Reputation: 2812

Renaming controller method in ASP.NET MVC

Some time I would rename a method in a controller using VS's [Refactor->Rename] function which could rename the reference to the method in all call stack. However, in my view with cshtml, I have

<div id="search-form">
    @*Render the search form *@
    @Html.Action("SearchUsers", "ManageAdmin")

The refactor function could not locate the controller method in order to rename, so I have to manually modify it. How would you make the renaming of controller's methods more automatic?

Upvotes: 0

Views: 1024

Answers (1)

Erik Funkenbusch
Erik Funkenbusch

Reputation: 93444

Unfortunately, you can't. At least not with Visual Studio's built-in rename. Razor pages are runtime components, not compile time. Visual Studio's intellisense doesn't know about runtime functions.

There are third party tools, like JetBrains ReSharper that have more advanced rename functionality that would find this.. but they aren't cheap.

Upvotes: 1

Related Questions