-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Improve IFormCollection.Items documentation #44372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
a047a2c
c713ec2
8c59e48
7cb20e1
d17f09f
c69050a
4acb483
89d0f6d
71ccec3
a0cda87
2fcbd03
eb205be
da246a6
d734917
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,10 +77,24 @@ public interface IFormCollection : IEnumerable<KeyValuePair<string, StringValues | |
/// <exception cref="System.ArgumentNullException"> | ||
/// key is null. | ||
/// </exception> | ||
/// <exception cref="System.InvalidOperationException"> | ||
/// incorrect content-type. | ||
/// </exception> | ||
/// <remarks> | ||
/// <para> | ||
/// <see cref="IFormCollection" /> has a different indexer contract than | ||
/// <see cref="IDictionary{TKey, TValue}" />, as it will return <c>StringValues.Empty</c> for missing entries | ||
/// rather than throwing an Exception. | ||
/// </para> | ||
/// <para> | ||
/// This indexer can only be used on POST requests. Otherwise an exception of type | ||
/// <see cref="System.InvalidOperationException" /> is thrown. | ||
/// </para> | ||
/// <para> | ||
/// Invoking this property could result in thread exhaustion since it's wrapping an asynchronous implementation. | ||
/// To prevent this the method <see cref="HttpContext.Request.ReadFormAsync()" /> can be used. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
sebastienros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// For more information, see <see href="https://aka.ms/aspnet/forms-async" />. | ||
/// </para> | ||
/// </remarks> | ||
StringValues this[string key] { get; } | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,11 +101,10 @@ public IFormCollection ReadForm() | |
|
||
if (!HasFormContentType) | ||
{ | ||
throw new InvalidOperationException("Incorrect Content-Type: " + _request.ContentType); | ||
throw new InvalidOperationException("This request does not have a Content-Type header. Forms are available from requests with bodies like POSTs and a form Content-Type of either application/x-www-form-urlencoded or multipart/form-data."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think this is not correct, request can have a I personally liked having the actual Should this also be updated? |
||
} | ||
|
||
// TODO: Issue #456 Avoid Sync-over-Async http://blogs.msdn.com/b/pfxteam/archive/2012/04/13/10293638.aspx | ||
// TODO: How do we prevent thread exhaustion? | ||
// c.f., https://aka.ms/aspnet/forms-async | ||
return ReadFormAsync().GetAwaiter().GetResult(); | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.