Merge branch 'rel/2.0.0-preview1' into dev
This commit is contained in:
commit
0c70cdb8df
|
|
@ -13,7 +13,7 @@ namespace MvcSandbox
|
|||
public IActionResult OnPost(string name)
|
||||
{
|
||||
Name = name;
|
||||
return View();
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
|
|||
/// <summary>
|
||||
/// Executes a Razor Page asynchronously.
|
||||
/// </summary>
|
||||
public virtual Task ExecuteAsync(PageContext pageContext, PageViewResult result)
|
||||
public virtual Task ExecuteAsync(PageContext pageContext, PageResult result)
|
||||
{
|
||||
if (result.Model != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -394,7 +394,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Internal
|
|||
|
||||
if (result == null)
|
||||
{
|
||||
result = new PageViewResult(_page);
|
||||
result = new PageResult(_page);
|
||||
}
|
||||
|
||||
await result.ExecuteResultAsync(_pageContext);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -56,11 +56,6 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="RazorPages.Page"/> instance this model belongs to.
|
||||
/// </summary>
|
||||
public Page Page => PageContext?.Page;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="RazorPages.PageContext"/>.
|
||||
/// </summary>
|
||||
|
|
@ -798,6 +793,12 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
|
|||
public virtual NotFoundObjectResult NotFound(object value)
|
||||
=> new NotFoundObjectResult(value);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="PageResult"/> object that renders the page.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="PageResult"/>.</returns>
|
||||
public virtual PageResult Page() => new PageResult(PageContext.Page, this);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the file specified by <paramref name="physicalPath" /> (<see cref="StatusCodes.Status200OK"/>) with the
|
||||
/// specified <paramref name="contentType" /> as the Content-Type.
|
||||
|
|
@ -1546,15 +1547,6 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
|
|||
public virtual UnauthorizedResult Unauthorized()
|
||||
=> new UnauthorizedResult();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="PageViewResult"/> object that renders the page.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="PageViewResult"/>.</returns>
|
||||
protected internal PageViewResult View()
|
||||
{
|
||||
return new PageViewResult(Page);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the specified <paramref name="model"/> instance.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -11,23 +11,23 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
|
|||
/// <summary>
|
||||
/// An <see cref="ActionResult"/> that renders a Razor Page.
|
||||
/// </summary>
|
||||
public class PageViewResult : ActionResult
|
||||
public class PageResult : ActionResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="PageViewResult"/>.
|
||||
/// Initializes a new instance of <see cref="PageResult"/>.
|
||||
/// </summary>
|
||||
/// <param name="page">The <see cref="RazorPages.Page"/> to render.</param>
|
||||
public PageViewResult(Page page)
|
||||
/// <param name="page">The <see cref="RazorPages.PageBase"/> to render.</param>
|
||||
public PageResult(PageBase page)
|
||||
{
|
||||
Page = page;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="PageViewResult"/> with the specified <paramref name="model"/>.
|
||||
/// Initializes a new instance of <see cref="PageResult"/> with the specified <paramref name="model"/>.
|
||||
/// </summary>
|
||||
/// <param name="page">The <see cref="RazorPages.Page"/> to render.</param>
|
||||
/// <param name="page">The <see cref="RazorPages.PageBase"/> to render.</param>
|
||||
/// <param name="model">The page model.</param>
|
||||
public PageViewResult(Page page, object model)
|
||||
public PageResult(PageBase page, object model)
|
||||
{
|
||||
Page = page;
|
||||
Model = model;
|
||||
|
|
@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
|
|||
/// <summary>
|
||||
/// Gets the <see cref="RazorPages.Page"/> to execute.
|
||||
/// </summary>
|
||||
public Page Page { get; }
|
||||
public PageBase Page { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the HTTP status code.
|
||||
|
|
@ -674,7 +674,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Internal
|
|||
_executeAction = executeAction;
|
||||
}
|
||||
|
||||
public override Task ExecuteAsync(PageContext pageContext, PageViewResult result)
|
||||
public override Task ExecuteAsync(PageContext pageContext, PageResult result)
|
||||
=> _executeAction(pageContext);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1422,7 +1422,6 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
|
|||
};
|
||||
|
||||
// Act & Assert
|
||||
Assert.Same(page, pageModel.Page);
|
||||
Assert.Same(pageContext, pageModel.PageContext);
|
||||
Assert.Same(pageContext, pageModel.ViewContext);
|
||||
Assert.Same(httpContext, pageModel.HttpContext);
|
||||
|
|
@ -1491,10 +1490,10 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
|
|||
};
|
||||
|
||||
// Act
|
||||
var result = pageModel.View();
|
||||
var result = pageModel.Page();
|
||||
|
||||
// Assert
|
||||
var pageResult = Assert.IsType<PageViewResult>(result);
|
||||
var pageResult = Assert.IsType<PageResult>(result);
|
||||
Assert.Same(page, pageResult.Page);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,14 +8,14 @@
|
|||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
return View();
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
await TaskCache.CompletedTask;
|
||||
MethodName = nameof(OnPostAsync);
|
||||
return View();
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task OnGetCustomer()
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ namespace RazorPagesWebSite
|
|||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
return View();
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
await TaskCache.CompletedTask;
|
||||
MethodName = nameof(OnPostAsync);
|
||||
return View();
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task OnGetCustomer()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
{
|
||||
Message = "From OnGet";
|
||||
|
||||
return View();
|
||||
return Page();
|
||||
}
|
||||
public string Message { get; set; } = "Default";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@
|
|||
{
|
||||
public IActionResult OnPostEdit(int id)
|
||||
{
|
||||
return View();
|
||||
return Page();
|
||||
}
|
||||
|
||||
public IActionResult OnPostDelete(int id)
|
||||
{
|
||||
return View();
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ namespace RazorPagesWebSite.TempData
|
|||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
return View();
|
||||
return Page();
|
||||
}
|
||||
|
||||
public IActionResult OnPost()
|
||||
{
|
||||
Message = "Secret post";
|
||||
return View();
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue