Should I specify an specific ActionResult or use the abstract class in my ASP.NET MVC AJAX methods?

StackOverflow https://stackoverflow.com/questions/22572054

문제

If I have an action method that I know it will only be called via AJAX and always returning JSON...

Do I set the method return type to JsonResult or leave it to ActionResult?

Please explain the reason of the choice.

도움이 되었습니까?

해결책

You should declare your action methods as returning ActionResult, so that they have the freedom to return any concrete result class.

Check this answer: https://stackoverflow.com/a/15250991/7720

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top