2

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.

tereško
  • 58,060
  • 25
  • 98
  • 150
Dacrocky
  • 447
  • 5
  • 12
  • Does this answer your question? [Must ASP.NET MVC Controller Methods Return ActionResult?](https://stackoverflow.com/questions/1021568/must-asp-net-mvc-controller-methods-return-actionresult) – General Grievance Dec 21 '21 at 15:00

2 Answers2

6

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.

Craig Stuntz
  • 125,891
  • 12
  • 252
  • 273
  • Yeah my question probably didn't make sense all that much, but this is what i wanted to know. thanks – Dacrocky Mar 02 '09 at 16:57
-2

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?

Inferis
  • 4,582
  • 5
  • 37
  • 47