Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

nameof cannot be used for Controller names in methods like RedirectToAction #2586

Closed
rustd opened this issue May 20, 2015 · 3 comments
Closed
Labels

Comments

@rustd
Copy link

rustd commented May 20, 2015

I wanted to use nameof in our templates for controller names and actions. I can use them fine for action names but when I try to use it for Controller names, I get runtime errors about routes not being found,

The following code results in /HomeController/Index instead of /Home/Index

RedirectToAction(nameof(HomeController.Index), nameof(HomeController))
@rustd
Copy link
Author

rustd commented May 20, 2015

@DamianEdwards @Eilon this was for Beta5 for the templates. it would be great if we can get this in. not sure though

@pranavkm
Copy link
Contributor

One possible suggestion was to remove the Controller suffix in the templates:

namespace MyApp.Controllers
{
    public class Home : Controller
    {
       public void Index()
       {
       }
   }
}

This way we don't have to mess with strings when resolving controller names.

@danroth27
Copy link
Member

No plans to change anything here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants