Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1071427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:42:49+00:00 2026-05-16T20:42:49+00:00

In ASP.Net MVC if I have a method on a controller that returns a

  • 0

In ASP.Net MVC if I have a method on a controller that returns a View should that method be of type ViewResult or the more general ActionResult?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:42:49+00:00Added an answer on May 16, 2026 at 8:42 pm

    A similar question was asked on the ASP.NET forums: http://forums.asp.net/t/1423519.aspx

    Basically, it comes down to style — in OOP, you try to return the most specific type that you can given the situation. You don’t return object for every method that you have — sometimes you return string, sometimes List, sometimes a custom class.

    In the forum replies, someone quotes Stephen Walther from his book:

    NOTE This action method specifically
    declares that it returns an instance
    of ViewResult. It would work just the
    same if instead the method return type
    was ActionResult (the base class for
    all action results). In fact, some
    ASP.NET MVC programmers declare all
    their action methods as returning a
    nonspecific ActionResult, even if they
    know for sure that it will always
    return one particular subclass.
    However, it’s a well-established
    principle in object-oriented
    programming that methods should return
    the most specific type they can (as
    well as accepting the most general
    parameter types they can). Following
    this principle maximizes convenience
    and flexibility for code that calls
    your method, such as your unit tests.

    So using the more specific ViewResult would be preferred, especially from a unit testing perspective.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In an asp.net mvc application I have a method that returns a JsonResult to
On ASP.NET MVC 3, assume that we have following controller action: public ActionResult Index()
I have an Action method in an ASP.NET MVC Controller class that handles form
I have an application (ASP.NET MVC) that uses a Next New method to get
I have an ASP.NET MVC project with a form. In the Action method that
In ASP.NET MVC I have a controller that looks somehow like this: public class
ASP.Net MVC Controllers have several methods of forwarding control to another controller or action.
I'm trying to get an ASP.NET MVC app working... I should have known it
I'm using ASP.NET MVC 3 (Razor) and have created a Controller named Controllers -
I have a site that was using ASP.Net MVC Beta 5, and I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.