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 9290619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:27:46+00:00 2026-06-18T20:27:46+00:00

What is the difference between the following two controller ActionResult return statements: return new

  • 0

What is the difference between the following two controller ActionResult return statements:

return new RedirectResult("http://www.google.com", false);

and

return Redirect("http://www.google.com");
  • 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-06-18T20:27:47+00:00Added an answer on June 18, 2026 at 8:27 pm

    straight from the source

    // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
    
    using System.Diagnostics.CodeAnalysis;
    using System.Web.Mvc.Properties;
    
    namespace System.Web.Mvc
    {
        // represents a result that performs a redirection given some URI
        public class RedirectResult : ActionResult
        {
            [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "0#", Justification = "Response.Redirect() takes its URI as a string parameter.")]
            public RedirectResult(string url)
                : this(url, permanent: false)
            {
            }
    
            [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "0#", Justification = "Response.Redirect() takes its URI as a string parameter.")]
            public RedirectResult(string url, bool permanent)
            {
                if (String.IsNullOrEmpty(url))
                {
                    throw new ArgumentException(MvcResources.Common_NullOrEmpty, "url");
                }
    
                Permanent = permanent;
                Url = url;
            }
    
            public bool Permanent { get; private set; }
    
            [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "Response.Redirect() takes its URI as a string parameter.")]
            public string Url { get; private set; }
    
            public override void ExecuteResult(ControllerContext context)
            {
                if (context == null)
                {
                    throw new ArgumentNullException("context");
                }
                if (context.IsChildAction)
                {
                    throw new InvalidOperationException(MvcResources.RedirectAction_CannotRedirectInChildAction);
                }
    
                string destinationUrl = UrlHelper.GenerateContentUrl(Url, context.HttpContext);
                context.Controller.TempData.Keep();
    
                if (Permanent)
                {
                    context.HttpContext.Response.RedirectPermanent(destinationUrl, endResponse: false);
                }
                else
                {
                    context.HttpContext.Response.Redirect(destinationUrl, endResponse: false);
                }
            }
        }
    }
    

    The second argument determines whether the response is a 302 (temporary) or 301 permanent redirection. By default, the value is false.

    The second method is on Controller and is simply a convenience method. This method has been around for a number of versions of MVC (as far back as at least 2), but IIRC, the addition of the Permanent part to RedirectResult I think has come in in MVC 4 (I don’t recall seeing it in MVC 3).

    // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
    
    using System.Diagnostics.CodeAnalysis;
    using System.Globalization;
    using System.IO;
    using System.Security.Principal;
    using System.Text;
    using System.Web.Mvc.Async;
    using System.Web.Mvc.Properties;
    using System.Web.Profile;
    using System.Web.Routing;
    namespace System.Web.Mvc
    {
        [SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "Class complexity dictated by public surface area")]
        public abstract class Controller : ControllerBase, IActionFilter, IAuthorizationFilter, IDisposable, IExceptionFilter, IResultFilter, IAsyncController, IAsyncManagerContainer
        {
          // omitted for brevity
    
          [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "0#", Justification = "Response.Redirect() takes its URI as a string parameter.")]
          protected internal virtual RedirectResult Redirect(string url)
          {
              if (String.IsNullOrEmpty(url))
              {
                  throw new ArgumentException(MvcResources.Common_NullOrEmpty, "url");
              }
    
              return new RedirectResult(url);
          }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a difference between the following two statements: mysql> EXPLAIN SELECT IF(arms IS
Is there any performance difference between the following two statements? from item in collection
Quick question, what is the difference between the following two declarations: define('I_LIKE_AT_SIGNS', false); and
Where is the difference between the following two Statements? print surname= ,$myVal, \n; and
Is there any difference between the following two code samples? var label:Label = new
Is there any difference between following two ways of creating an object. Student s1
Is there any difference between the following two examples and should one be preferred
Is there a difference between the following two : ArrayList list = getData(); public
What is difference between the following two function definitions? A 2D array is being
What's the difference between the following two? The first 1 works but the 2nd

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.