// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.AspNetCore.Mvc.ViewEngines; using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.AspNetCore.Mvc { /// /// Represents an that renders a partial view to the response. /// public class PartialViewResult : ActionResult { /// /// Gets or sets the HTTP status code. /// public int? StatusCode { get; set; } /// /// Gets or sets the name or path of the partial view that is rendered to the response. /// /// /// When null, defaults to . /// public string ViewName { get; set; } /// /// Gets the view data model. /// public object Model => ViewData?.Model; /// /// Gets or sets the used for rendering the view for this result. /// public ViewDataDictionary ViewData { get; set; } /// /// Gets or sets the used for rendering the view for this result. /// public ITempDataDictionary TempData { get; set; } /// /// Gets or sets the used to locate views. /// /// When null, an instance of from /// ActionContext.HttpContext.RequestServices is used. public IViewEngine ViewEngine { get; set; } /// /// Gets or sets the Content-Type header for the response. /// public string ContentType { get; set; } /// public override Task ExecuteResultAsync(ActionContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var services = context.HttpContext.RequestServices; var executor = services.GetRequiredService>(); return executor.ExecuteAsync(context, this); } } }