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

Action results pattern #657

Closed
yishaigalatzer opened this issue Jun 12, 2014 · 3 comments
Closed

Action results pattern #657

yishaigalatzer opened this issue Jun 12, 2014 · 3 comments

Comments

@yishaigalatzer
Copy link
Contributor

Examples:

JsonResult allow status code on JsonResult.

RedirectResult exposes the url but doesn't let you change it.

Also redirectresult eagerly resolves UrlHelper just to find out if a Url is local (which means a service is resolved on every call unnecessarily).

See:
https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNet.Mvc.Core/ActionResults/RedirectResult.cs#L35

Suggested pattern: Every result exposes properties as get set, so results filters can modify them and observe the values.

Services are resolved on a per needed basis, and not eagerly.

Static things like IsLocalUrl are not done as Transient services, they can either be static methods or Singleton services.

@javiercn
Copy link
Member

Needs discussion and break down.

@rynowak
Copy link
Member

rynowak commented Jan 16, 2015

Doing a pass and cleaning this up things that should be true in general.

Properties are get/set by default

  • Some require a not-null value (FileStreamResult)
  • Services needed by the result are get/set and default to null. They are resolved inside Execute

Exception to this is HttpStatusCodeResult and derived classes. Since all this class does is set a status code, it's not get/set. Then you can't end up with an NotFoundResult(201) or other nonsense.

Adding a StatusCode property to the more complex result types where it makes sense. (ViewResult, ContentResult, but not FileResult).

rynowak added a commit that referenced this issue Jan 16, 2015
In general all properties are get/set so filters can change them.
 - some validate for not-null
 - where we use services it's get/set also

Services are resolved in the Execute method if not provided.

A few more ActionResults that return a body have the ability to set a
status code now (optional).
rynowak added a commit that referenced this issue Jan 16, 2015
In general all properties are get/set so filters can change them.
 - some validate for not-null
 - where we use services it's get/set also

Services are resolved in the Execute method if not provided.

A few more ActionResults that return a body have the ability to set a
status code now (optional).
rynowak added a commit that referenced this issue Jan 17, 2015
In general all properties are get/set so filters can change them.
 - some validate for not-null
 - where we use services it's get/set also

Services are resolved in the Execute method if not provided.

A few more ActionResults that return a body have the ability to set a
status code now (optional).
@rynowak
Copy link
Member

rynowak commented Jan 17, 2015

692a072

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

No branches or pull requests

4 participants