Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Commit 00c38fc

Browse files
committed
Add ModelState to Page
1 parent 145d27f commit 00c38fc

File tree

1 file changed

+12
-1
lines changed
  • src/Microsoft.AspNetCore.Mvc.RazorPages

1 file changed

+12
-1
lines changed

src/Microsoft.AspNetCore.Mvc.RazorPages/Page.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Diagnostics;
6+
using Microsoft.AspNetCore.Mvc.ModelBinding;
67
using Microsoft.AspNetCore.Mvc.Razor;
78
using Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure;
89
using Microsoft.AspNetCore.Mvc.ViewFeatures;
@@ -18,10 +19,13 @@ public abstract class Page : RazorPageBase, IRazorPage
1819
private PageArgumentBinder _binder;
1920

2021
/// <summary>
21-
/// The <see cref="PageContext"/>.
22+
/// The <see cref="RazorPages.PageContext"/>.
2223
/// </summary>
2324
public PageContext PageContext { get; set; }
2425

26+
/// <summary>
27+
/// Gets or sets the <see cref="PageArgumentBinder"/>.
28+
/// </summary>
2529
public PageArgumentBinder Binder
2630
{
2731
get
@@ -45,6 +49,11 @@ public PageArgumentBinder Binder
4549
}
4650
}
4751

52+
/// <summary>
53+
/// Gets the <see cref="ModelStateDictionary"/>.
54+
/// </summary>
55+
public ModelStateDictionary ModelState => PageContext?.ModelState;
56+
4857
/// <summary>
4958
/// Gets the <see cref="ITempDataDictionary"/> from the <see cref="PageContext"/>.
5059
/// </summary>
@@ -57,6 +66,7 @@ public override void EnsureRenderedBodyOrSections()
5766
throw new NotSupportedException();
5867
}
5968

69+
/// <inheritdoc />
6070
public override void BeginContext(int position, int length, bool isLiteral)
6171
{
6272
const string BeginContextEvent = "Microsoft.AspNetCore.Mvc.Razor.BeginInstrumentationContext";
@@ -76,6 +86,7 @@ public override void BeginContext(int position, int length, bool isLiteral)
7686
}
7787
}
7888

89+
/// <inheritdoc />
7990
public override void EndContext()
8091
{
8192
const string EndContextEvent = "Microsoft.AspNetCore.Mvc.Razor.EndInstrumentationContext";

0 commit comments

Comments
 (0)