u936293
u936293

Reputation: 16244

Attribute to make Action not available

I want to retain the code of some unused methods in my controllers in case I need them again in future.

To prevent accidental access, I thought of using the following attribute to mark all such methods:

[Authorize(Roles="This Role will never be assigned.")]

This works, but only after first getting the user to log in. Is there a more elegant way?

Upvotes: 0

Views: 119

Answers (1)

nforss
nforss

Reputation: 1258

Use The NonActionAttribute. It allows you to mark public methods in a controller as not being available for external requests.

Here's more information.

Upvotes: 1

Related Questions