Question

Can a so called action in my controller just be a regular function that returns anything I want or does the return of an ActionResult declare whether its an "action" or not?

I was wondering if i could call functions in my ActionLink in the "actionname" that didn't return actionresults.

Was it helpful?

Solution

All public methods of a controller are actions by default, regardless of return type. So, yes, you can call them. Use [NonActionAttribute] to override this default.

OTHER TIPS

Yes, all actions should return an ActionResult. The MVC engine only know to handle an ActionResult (or a derivative).

I don't understand what you mean with "call functions in my ActionLink that don't return ActionResults". Even if you don't want to return any meaning, you still have to return an ActionResult.

What is it you want to accomplish?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top