Skip to content

Add EmptyHttpRequest Indexer #132

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

EmondDeW
Copy link

The virtual indexer of the base class (HttpRequestBase) throws NotImplementedException.

This implementation follows the order of probing of the collection that is used in HttpRequest.

@@ -172,6 +172,7 @@ public EmptyHttpRequest (HttpRequestBase originalRequest)
public override string ContentType { get { return _originalRequest.ContentType; } set { } }
public override System.Text.Encoding ContentEncoding { get { return _originalRequest.ContentEncoding; } set { } }
public override RequestContext RequestContext { get; set; }
public override string this[string key] => QueryString[key] ?? Form[key] ?? Cookies[key]?.Value ?? ServerVariables[key];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or you could also

Suggested change
public override string this[string key] => QueryString[key] ?? Form[key] ?? Cookies[key]?.Value ?? ServerVariables[key];
public override string this[string key] => _originalRequest[key];

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I am not sure if/what EMPTYHttpRequest should return in the first place... I just don't want it to throw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants