batch endpoint properly.
The root cause is that the base uri of ODataMessageReaderSettings doesn't
end with slash.
The fix is only for v3 and v4 works well for all kinds of urls because
ODL v4 will append a slash in the end of the base uri if there isn't one.
The issue here is that one of the requests in a batch was matched by an
MVC route when running in web host.
The batch handler uses HttpServer to invoke the individual requests.
Internally the HttpServer forwards the request to an
HttpRoutingDispatcher.
In the web host case, the HttpRoutingDispatcher has a reference to
HostedHttpRouteCollection - which is implemented by matching BOTH WebAPI
and MVC (System.Web) routes. If an MVC route matches, then the produced
IHttpRouteData instance doesn't have its .Route property set as the
underlying route that matched does not implement IHttpRoute.
This causes attribute routing in the controller selector to fail, as we
did not anticipate this case.
Followup filed to consider whether or not this is the right behavior for
the dispatcher/route-collection.
(cherry picked from commit f9a064cbf2)
The issue here is that one of the requests in a batch was matched by an
MVC route when running in web host.
The batch handler uses HttpServer to invoke the individual requests.
Internally the HttpServer forwards the request to an
HttpRoutingDispatcher.
In the web host case, the HttpRoutingDispatcher has a reference to
HostedHttpRouteCollection - which is implemented by matching BOTH WebAPI
and MVC (System.Web) routes. If an MVC route matches, then the produced
IHttpRouteData instance doesn't have its .Route property set as the
underlying route that matched does not implement IHttpRoute.
This causes attribute routing in the controller selector to fail, as we
did not anticipate this case.
Followup filed to consider whether or not this is the right behavior for
the dispatcher/route-collection.
If client sends a request with Prefer: return=minimal, and then service
may return an http status code 204 without response content, and also add
a response header OData-EntityId.
"if the service applies a return=minimal preference. In this case, the
response body MUST be empty."
Change Prefer return parameter to: return=representation, and return=minimal
For a response to a create (post/patch/put) operation, add OData-EntityId header,
if response is with status code: NoContent
[Codeplex #1900]: ODataMediaTypes.GetMetadataLevel()` calculates incorrect
default metadata level
Summary of this fix:
1. clean the ODataMetaDataLevel.Default
2. Calculate the correct metadata level
3. fix the corresponding test cases
navigation source
1.If the user defines the return type of action/function by calling
"ReturnsEntityViaEntitySetPath<T>(entitySetPath)", we will call
"TryGetRelativeEntitySetPath(...) to get the target navigation source.
2.If the user defines the return type and the returned navigation source by
calling "ReturnFromEntitySet<T>(entitysetName)", we will define an
instance of "ReturnedEntitySetAnnotation" with the entity set name and set
it as an annotation in the Edm Model. When we dispose the action/function
call, we will get the annotation from the model and use the entity set
name in the annotation to find the target navigation source.
- Modify tests to account for new behavior.
- Only trigger one Facebook prompt hook per request.
- Expose new ShowPromptResult and JavaScriptRedirectResult.
on the response payload
Serialize null single valued navigation property as null in payload.
Serialize null collection valued navigation property as empty collection
in payload. Previously, they were not serialized, i.e., missing in
payload.
Based on profiling, found out that if an OData route prefix is null, the
existing ODataRoute.GetVirtualPath method does not call
GenerateLinkDirectly to generate an optimized direct link, instead
base.GetVirtualPath is invoked.
Add the support *PUT/PATCH* to a single-valued navigation property in
convention routing. But, it is not valid to *Put/Patch" to any collection-valued navigation property.
The root cause is that we catch ODataException only to create error
response, however NotImplementedException, NotSupportedException and
InvalidOperationException may throw for bad query string.
We need to catch all these exceptions to create error response.
This fix is not mapping derived types because it will break all the query
composition scenarios.
In this fix, I improve the error message to make
the message actionable and give out the workaround.
- route values are not configured when constraints execute during URI
resolution; that configuration occurs after all constraints are done
- this causes the UrlHelper to incorrectly calculate the service root,
expecially when the OData route prefix contains parameters
- in addition ODataPathRouteConstraint should not use UrlHelper since
constraints operate at a much lower abstraction level
- use RequestUri and route values directly to determine service root
Also fixes#1916, which relates to not using the application base
- that fix comes from different approach taken here
Require that ODataPath be in the RequestUri
- ODataRoute's template ensures this is true
- basically remove a special case from the product code
- fix the tests which required the special case
Revise ODataPath matching to provide ODL with escaped service root
- necessary to avoid incorrect escaping and unrelated links in responses
- add lower-level unit tests of ODataPathRouteConstraint
Handle corner case in `ODataPathRouteConstraint`
- an escaped slash may separate OData path from app base / virtual path
root / OData prefix before it
- but ODL and `DefaultODataPathHandler` expect a literal '/'
[Codeplex #1939]: Should do some clean up in ODataMediaTypeFormatters.CreateApplicationXml
codeplex #1917 only mentions to clean up the service document in
application/xml. But, as a fact, ODL only supports Metadata document in
application/xml format. For other payload kinds (for example, Property, EntityReferenceLink(s), Collection, Error) are not supported any more as application/xml format in ODL.
codeplex #1939 is required to clean up all other not-supported payload kinds from application/xml format. The requirement is similar with the above and the fix is same.
So, this changeset merges them together. Thanks.
Previously if a user wanted to only have default user permissions (which we support) the app would explode on redirects due to the model binder ensuring permissions existed.
Added a PrePermissionPromptHook, a DeniedPermissionPromptHook and added the infrastructure to support custom ActionResult responses from them in order to fully control the Facebook app login flow. Also added a new method to IFacebookPermissionService to utilize externally and internally for getting a users permission status.
1. Source of CollectionFunctionCallNode
2. Source of CollectionNavigationNode
3. Source of CollectionOpenPropertyAccessNode
4. Source of CollectionPropertyAccessNode
5. Source of CollectionPropertyCastNode
6. Source of EntityCollectionCastNode
7. Source of EntityCollectionFunctionCallNode
8. Source of SingleEntityCastNode
9. Source of SingleEntityFunctionCallNode
10. Source of SingleNavigationNode
11. Source of SingleValueCastNode
12. Source of SingleValueFunctionCallNode
13. Source of SingleValueOpenPropertyAccessNode
14. Source of SingleValuePropertyAccessNode
If a navigation source has a navigation property which is binding to a
single-valued object or non-collection valued object, then *post to* this
navigation property is not allowed.
Remove the string overload of HasEditLink, HasReadLink:
A link has to be a Uri as per OData spec.
The string overload is only referenced by a test method.
OData-Version header values (V3 version)
https://aspnetwebstack.codeplex.com/workitem/1749
This fix adds a version constraint to the ODataRoute that will prevent
it from matching any request with a v4 version header or a request with
a v1-v3 version header whose value is outside of the range of this
constraint. The default range for the constraint is 1.0 to 3.0, but this
can be changed by removing the constraint and adding a different one
with a different range. This constraint will still match any request
without version headers.
OData-Version header values (V4 version)
https://aspnetwebstack.codeplex.com/workitem/1749
This fix adds a version constraint to the ODataRoute that will prevent
it from matching any request with a v3 version header or a request
with a v4 version header whose value is different than 4.0.
This constraint will still match any request without version headers.
Conflicts:
test/System.Web.OData.Test/HttpRouteCollectionExtensionsTest.cs
is requested.
https://aspnetwebstack.codeplex.com/workitem/1718
This change fixes the broader problem by handling null values in general,
not just for raw values. We replaced ODataNullValueAttribute with
ODataNullValueMessageHandler. This message handler will convert null
requests for individual entities or singletons into 404 responses and
will convert null requests for non collection properties (navigation
or structural) into 204 responses. This behaviour is not enabled by
default. The user needs to plug in the message handler as a per route
handler when he registers the OData route.
annotation, the ETag header should also be set.
https://aspnetwebstack.codeplex.com/workitem/1711
Created a specific MapODataServiceRoute overload to make registering
per route HttpMessageHandlers in OData routes easier.
annotation, the ETag header should also be set.
https://aspnetwebstack.codeplex.com/workitem/1711
Created an ODataETagMessageHandler to take care of calculating and
adding the ETag Header to the response when it's a successful response
that returns a single resource with an ETag defined and the response
status code is different than NoContent.
ODL 6.3 is released and available on nuget along with the source code.
Here is the change summary of ODL in this release:
1. Fix a bug for serializing floating-point values to NaN, INF, and -INF.
2. EdmLib & ODataLib now supports model reference.
3. ODataLib now supports reading and writing delta response.
4. EdmxReader supports ignoring the unknown attribute/element in new
TryParse API.
5. ODataUriParser adds support for parsing relative Uri without service
root
So, The summary in this migration is:
1. Update to ODL V6.3 package
2. Fix the test cases.
the spec. https://aspnetwebstack.codeplex.com/workitem/1810
The actual issue is that the version that was being calculated is the one for the
response and the codeplex issue describes the algorithm that calculates the request
version.
This change refactors the current v4 implementation for calculating the response by
moving the constants for the version headers to HttpRequestMessageProperties,
defining separate internal properties for the values of the OData-Version and
OData-MaxVersion and moving the logic for calculating the version to use in the
response to the ODataMediaTypeFormatter.
the spec. https://aspnetwebstack.codeplex.com/workitem/1810
The actual issue is that the version that was being calculated is the one for the
response and the codeplex issue describes the algorithm that calculates the request
version.
This change refactors the current v4 implementation for calculating the response by
moving the constants for the version headers to HttpRequestMessageProperties,
defining separate internal properties for the values of the OData-Version and
OData-MaxVersion and moving the logic for calculating the version to use in the
response to the ODataMediaTypeFormatter.
Issue 1751: OData V4 Responses MUST include the odata.metadata parameter(odata.metadata=full,
odata.metadata=minimal or odata.metadata=none) to specify the amount of metadata
included in the response in V4
https://aspnetwebstack.codeplex.com/workitem/1751
Issue 1741: Charset parameter should not show in Content-Type in response if Accept in request
don't has it
Rewrote SetDefaultContentHeaders in ODataMediaTypeFormatter to fix both issues.
https://aspnetwebstack.codeplex.com/workitem/1768
Reverted a change that made the internal cache of EdmStructuredObject
use a tuple of the property name and the IEdmStructruredType instead
of a tuple of the property name and the object type as the key for the
cache.
The issue was caused because the GetOrCreatePropertyGetter method
incorrectly cached a getter delegate using the EF dynamic proxy and
later on it tried to use that same getter with the actual type, which
resulted on a cast exception.
Reverting the cache to use the type instead of the IEdmStructuredType
will solve that problem as each type will have it's own getter. This is
also the behaviour the system exposed before model aliasing was
introduced.
exception without EnsureInitialized.
https://aspnetwebstack.codeplex.com/workitem/1752
This fix changes the behavior to be the same exposed by Web API, which is
throwing an InvalidOperationException with the same error message as in Web API.
apply at *any* properties.
In OData Convention Model Builder, it will the property
that is annotated with the Key attribute and follows the "schema Id |
TypeName + Id".
We should suppress the convention rule if any properties were annotated
with [key].
Here is the example which can illustrate this modification:
Suppose we have the CLR type as:
=========================================
public class Customer
{
[Key]
public string Path { get; set; }
public long CustomerId { get; set; }
...
}
Then, we use OData Convention Model builder to build the EdmModel:
=========================================
ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<Customer>("Customers");
....
builder.GetEdmModel();
In $metadata, there are two keys existed:
=========================================
<EntityType Name="Customer">
<Key>
<PropertyRef Name="CustomerId" />
<PropertyRef Name="Path" />
</Key>
<Property Name="Path" Type="Edm.String" Nullable="false" />
<Property Name="CustomerId" Type="Edm.Int64" Nullable="false" />
Originally, User is explicitly decorated [Path] as the key, so, the
[CustomerId] shouldn't treat as key. So, this modification will suppress key
convention once [Key] explicitly apply at *any* properties.
return IQueryable<T> instead of IQueryable.
https://aspnetwebstack.codeplex.com/workitem/1756
Added a generic overload on Etag<T> (The type of the IfMatch and IfNoneMatch
properties on ODataQueryOptions<T>).
HttpTaskAsyncHandler should not ever exceptions except in the case
of a really unfixable error. This change will call request.Abort() and
terminate gracefully instead of reporting an error.
issue-#1789 must also be fixed for this to handle all cases. Right now
this can only handle cases where we fail deep in infrastructure methods.
- provides default top-level element when not overridden in
`ValidationSummary()` calls
- also HtmlHelper access to ValidationSummaryMessageElement setting
This feature is to support open complex type in WebAPI.
Open Complex Type is a complex type with declared and dynamic properties.
The user can use IDictionary<string, object> to define a property in his
complex type (CLR class), then the WebApi model builder can build this
complex type as open complex type. The end user can post their dynamic
properties for this open complex type to the service in the payload, then
he can get their dynamic properties from the service in the future to do
futher process.
The Replace option currently available in AjaxOption replaces the contents
but not the element itself. The newly introduced ReplaceWith option
matches the replaceWith semantics of jQuery.
Work Item: 1500
handling/logging
The issue here is that when an action (or ApiController infrastucture)
throws an exception, it might be handled along one of two code paths
depending on whether or not any exception filters are configured.
If any exception filters are present, the logging/handling will take
place inside the 'IExceptionFilters' block. Otherwise logging/handling
will take place inside the 'HttpControllerDispatcher' block.
The 'IExceptionFilters' block would correctly provide a ControllerContext,
and the 'HttpControllerDispatcher' block did not.
The fix is to, when possible, provide a ControllerContext in the
'HttpControllerDispatcher' catch block. Note that it is only possible to
provide a ControllerContext when an exception was thrown the controller or
action itself. If an exception is thrown during controller selection or
controller activation, there is no context, and thus none provided.
disk
When dealing with precompiled 'non-updateable' applications, deleting
marker files was allowed in earlier iterations of Mvc. This change
restores this behavior.
Work Item: 1709
https://aspnetwebstack.codeplex.com/workitem/1838
Improve error message for the following case:
@if (true)
{
<script> var a= '<script></script>' </script>
}
The user code is wrong, and the script will be broken.
The browser will terminate the script at the first </script> inside
the string but will not report an error.
Razor catches it correctly, but the error message does not provide
enough clues to what went wrong.
Changes to support passing the original config in JQueryMVCFormUrlEncodedFormatter
Move Make HttpConfiguration constructor pass the
configuration into the JQueryMVCFOrUrlEncodedFormatter constructor and then pass it down to the FormDataCollectionExtensions.
Wrap the Configuration's Services to return only the necessary Services when ReadAs is called.
Adding Unit Tests.
1. Able to build an Edm model has a contained navigation property, using
convention model builder
Add a [Contained] attribute to mark a navigation property as containment.
2. Able to build a model has a contained navigation property, using model
builder
EntityTypeConfiguration<T>: ContainsMany, ContainsRequired,
ContainsOptional
These, and existing HasMany etc. can be used to override convention model
builder.
3. Able to build a model with a base type has a contained navigation
property, and the navigation property is inherited by a derived type,
using model builder and convention model builder.
4. Able to route for fundamental scenarios
../MyOrders(orderId)/OrdersLines
../MyOrders(orderId)/OrdersLines(lineId)
5. Able to serialize / des-serialize containment
6. Containment in expand
7. Calculate links via ODL
In derived scenario, when generate ID link (should be a Uri as per spec,
instead of string,) we should not append type cast at the end.
Previously, when webapi.odata generates an Id link, it will check if a
derived type has a nav prop, if yes, it will append a type cast (even if
the actual type is the same to the request one.)
After we leverage ODL for edit link generation, the edit link will be:
./service_root/es(key)/cast/cast
As per v4 spec, the editlink/readlink does include the type-cast; however,
according to convention the Id does NOT include the type-cast:
8. Fix test cases about editLink
9. Verify containment after composable function / action
Singleton is the new concept in OData V4. The meaning of it is to allow
user to create a special (unique) entity and such entity can be addressed
directly by its name. The behaviour of Singleton is very similar with
the behaviour of entity set but has different meanings.
Here is the scope of singleton feature:
1. Support Singleton configuration
2. Support Singleton manipulation on ODataModelBuilder
3. Support Singleton manipulation on ODataConventionModelBuilder
4. Support Singleton convention routing & attribute routing
5. Support Singleton serialization / dieselization
6. Support Singleton query option
7. Support Singleton navigation property
8. Support Singleton in Service document
9. Support Singleton action and function
The summary of migrating to latest ODL V6.2 from ODL V6.0 beta 1 :
1. Use ODL v6.2 RTM assemblies.
2. In ODataError, MessageLanguage is gone.
3. EnumNode is gone.
4. ElementType is gone -> EntityType().
5. WriteEntityReferenceLink -> one param.
6. EntityContainers() is gone -> EntityContainer, FindContainer is gone.
7. ReadEntityReferenceLink takes no param.
8. ParseOrderBy/Filter/SelectExpand static method is gone.
9. Version is gone in metadata.
10. IsAlwaysBindable is gone for action an function,SetIsAlwaysBindable is gone
11. GetServiceVersion is gone.
12. SetServiceDocumentUri is gone.
13. String function parameter should be single quoted.
14. Content-ID header check.
15. Change Enum value binder.
16. ODataUriNullValue -> ODataNullValue.
17. If an action or function is requested in a selectItem using a
qualifiedActionName or a qualifiedFunctionName and that operation cannot
be bound to the entities requested, the service MUST ignore the selectItem.
18. Only support Base64 format for binary.
19. Change to ODL V6.2 new UriParser for query option.
Since we do not know how the string will be parsed with a TypeConverter when generating the
sample query string, just do not display member properties of the type which is associated
with a TypeConverter. Instead, the type itself will be displayed.
This is a separated PR fixing 1567:
- Add support for generating query string of type Dictionary and KeyValuePair.
- Replace '.' with '-' in GetFriendlyId. Otherwise, RelativePath with . (like ModelType.Foo or ModelType[0].Foo)
will break the help page's uri
- Change the css of help page to make a long path more readable.
collection of primitive types and coming from Uri.
- Add support for primitive/complex collection(and arrays).
- separate helpers and increase readability.
- add XML comments
- use named parameters in added test methods (clarify nulls)
- rename added test methods to make expectations clear
- add three new tests to cover gaps
By adding a AreaReference enum, to be capable of setting Remote attribute or use the area which.
So, fix the problem of not being able to refer to the controller outside the area from inside the area.
resolved instances are only created once and then shared.
This fix only aims at the CreateActionInvoker() in the MVC Controller.
CreateTempDataProvider() will be fixed in a separate issue.
Moved ModelAliasingEnabled from ODataModelBuilder to ODataConventionModelBuilder.
Refactored the OData model builder conventions to take in an ODataConventionModelBuilder
instance.
The new IDirectRouteProvider api supports discovering IRouteFactory
on controller descriptors and action descriptors with arbitrary criteria.
DefaultDirectRouteProvider is given as a base class for customizing a
single aspect of the process.
Since criteria for whether or not an action/controller is attribute
routed is now arbitrary, I've added a marker to the descriptors. This
required some refactoring of the action selector, now caching proceeds in
two phases.
1. Existance of actions and descriptors are cached
2. Details used for action selection are cached.
2) will happen when requests come in, so attribute routing is allowed to
mark the descriptors before they are cached.
scenarios.
Renamed IDictionaryConvertible to ISelectExpandWrapper, made the
interface public public and changed the return type of its ToDictionary
method to IDictionary in order to allow using custom JsonConverters with
$select and $expand projections in both assemblies (v3 and v4).
https://aspnetwebstack.codeplex.com/workitem/1699
Per protocol bound action/function should not be added as
actionImport/functionImport. But now they become imports.
This bug is a regression from a previous checkin. I've fixed the bug and added
the respective unit tests to cover the cases that weren't tested and that caused
the behavior change to go undetected.
action/function.
ODL Spec Says:
11.5.3.1 Invoking a Function
...To invoke a function through a function import the client issues a GET
request to a URL identifying the function import and passing parameter
values using inline parameter syntax. The canonical URL for a function
import is the service root, followed by the name of the function import.
...
11.5.4.1 Invoking an Action
...To invoke an action through an action import, the client issues a POST
request to a URL identifying the action import. The canonical URL for an
action import is the service root, followed by the name of the action
import.
Add property `Group` into SelectListItem. Now DropDownList
, along with other kinds of select list, can render the <optgroup>
tag wrapping options if `Group` is set.
this action/function
[ODL spec says in 11.5.3.1 Invoking a Function]
To invoke a function bound to a resource, the client issues a GET request
to a function URL. A function URL may be obtained from a previously
returned entity representation or constructed by appending the namespace-
or alias-qualified function name to a URL that identifies a resource whose
type is the same as, or derived from, the type of the binding parameter of
the function. ....
read from Request.InputStream
If the result of GetBufferedInputStream was completely read, the buffered
stream is available via Request.InputStream. We can attempt to use instead
of proactively throwing.
Work Item: 1696
the binding parameter type MUST be unique within a namespace.
In this fix, a validation function added in GetEdmModel() to validate the
action overload:
1. For bound action overload, each overload action must have differnt
bingding type.
2. For unbound action, each unbound action must have different action
name.
Thanks.
and ConcurrencyCheckAttribute in ODataConventionModelBuilder
https://aspnetwebstack.codeplex.com/workitem/1423
Added support for ComplexTypeAttribute and TimestampAttribute, support for
ConcurrencyCheckAttribute already existed. Support for AssociationLinkAttribute
requires changes on the way we build the model that are out of the scope of
this fix.
https://aspnetwebstack.codeplex.com/workitem/1598
Setting is not navigable should also set IsNonFilterable and IsUnsortable
but not the opposite (setting IsNavigable should not set IsSortable or
IsFilterable)
Given a model with an entity, and a complex object. When we limit ordering in
the complex object it doesn't get respected and the following query succeeds
instead of returning bad request.
"/odata/QueryLimitCustomers?$orderby=HomeAddress/ZipCode"