2010-06-21 Marek Habersack <mhabersack@novell.com>
[mcs.git] / class / System.Web.Mvc / System.Web.Mvc / RedirectResult.cs
blobd6038fb4684eb112612fa139ff1a5e21f74c96c6
1 /* ****************************************************************************
3 * Copyright (c) Microsoft Corporation. All rights reserved.
5 * This software is subject to the Microsoft Public License (Ms-PL).
6 * A copy of the license can be found in the license.htm file included
7 * in this distribution.
9 * You must not remove this notice, or any other, from this software.
11 * ***************************************************************************/
13 namespace System.Web.Mvc {
14 using System;
15 using System.Diagnostics.CodeAnalysis;
16 using System.Web.Mvc.Resources;
18 // represents a result that performs a redirection given some URI
19 public class RedirectResult : ActionResult {
21 [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "0#",
22 Justification = "Response.Redirect() takes its URI as a string parameter.")]
23 public RedirectResult(string url) {
24 if (String.IsNullOrEmpty(url)) {
25 throw new ArgumentException(MvcResources.Common_NullOrEmpty, "url");
28 Url = url;
31 [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings",
32 Justification = "Response.Redirect() takes its URI as a string parameter.")]
33 public string Url {
34 get;
35 private set;
38 public override void ExecuteResult(ControllerContext context) {
39 if (context == null) {
40 throw new ArgumentNullException("context");
43 string destinationUrl = UrlHelper.Content(Url, context.HttpContext);
44 context.HttpContext.Response.Redirect(destinationUrl, false /* endResponse */);