Undo a breaking change

This commit is contained in:
Ryan Nowak 2017-09-22 14:16:11 -07:00
parent afdda7cbee
commit be5d4ec11e
2 changed files with 47 additions and 5 deletions

View File

@ -3,11 +3,16 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Core;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.Internal;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.Mvc
{
@ -216,5 +221,47 @@ namespace Microsoft.AspNetCore.Mvc
var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<RedirectToPageResult>>();
return executor.ExecuteAsync(context, this);
}
#pragma warning disable CS0809
[Obsolete("This implementation will be removed in a future release, use ExecuteResultAsync.")]
public override void ExecuteResult(ActionContext context)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
var services = context.HttpContext.RequestServices;
var urlHelperFactory = services.GetRequiredService<IUrlHelperFactory>();
var logger = services.GetRequiredService<ILogger<RedirectToPageResult>>();
var urlHelper = UrlHelper ?? urlHelperFactory.GetUrlHelper(context);
var destinationUrl = urlHelper.Page(
PageName,
PageHandler,
RouteValues,
Protocol,
Host,
fragment: Fragment);
if (string.IsNullOrEmpty(destinationUrl))
{
throw new InvalidOperationException(Resources.FormatNoRoutesMatchedForPage(PageName));
}
logger.RedirectToPageResultExecuting(PageName);
if (PreserveMethod)
{
context.HttpContext.Response.StatusCode = Permanent ?
StatusCodes.Status308PermanentRedirect : StatusCodes.Status307TemporaryRedirect;
context.HttpContext.Response.Headers[HeaderNames.Location] = destinationUrl;
}
else
{
context.HttpContext.Response.Redirect(destinationUrl, Permanent);
}
}
#pragma warning restore CS0809
}
}

View File

@ -1,7 +1,2 @@
[
{
"TypeId": "public class Microsoft.AspNetCore.Mvc.RedirectToPageResult : Microsoft.AspNetCore.Mvc.ActionResult, Microsoft.AspNetCore.Mvc.ViewFeatures.IKeepTempDataResult",
"MemberId": "public override System.Void ExecuteResult(Microsoft.AspNetCore.Mvc.ActionContext context)",
"Kind": "Removal"
}
]