Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all 7215 articles
Browse latest View live

Edited Issue: Make sure Attribute Routing and EnableCors play nicely together [954]

$
0
0
I just received a report from a user where he only uses attribute routing and because of the HTTP method route constraint that we create from the attribute, no other HTTP methods can reach the Web API pipeline. That’s problematic for the preflight requests which sends an OPTIONS.

[RoutePrefix("api/profiles")]
public class ProfilesController : ApiController
{
[System.Web.Http.HttpGet("{personId}/app/{appId}", RouteName = "ProfileApiGetPersonApp")]
public async Task<HttpResponseMessage> GetPersonApplicationProfile(Guid personId, Guid appId)

See the full context here: http://aspnetwebstack.codeplex.com/discussions/438303

Edited Issue: Consider supporting parsing and generating key values in KeyValuePathSegment [674]

$
0
0
So user doesn't need to call ODataUriUtils.ConvertToUriLiteral or ODataUriUtils.ConvertFromUriLiteral to parse the id by himself.

Edited Issue: consider how nulls are represented with IEdmObject. [1014]

$
0
0
IEdmObject right now tracks entity instances only which are not nullable. Once, we add support for IEdmObject with complex types and collections, we have to figure out a way to represent null values as IEdmObjects. One strategy could be to have EdmNullValue that implements IEdmObject.

Edited Issue: [OData] Add support for including non-key properties as well in the SelectExpand expression [1017]

$
0
0
We include the properties that the client has asked for (thorugh $select and $expand) and the entity keys in the projection expression we generate in the SelectExpandBinder.

If people customize their OData link generation, they might need to access to other properties as well. For example, lets say a Person entity has Id (key) and a Name, and, the generated links contain Name instead of Id.

We should add a setting on ODataQuerySettings to let people choose extra properties that they want to bring from their database.

Edited Issue: [CORS] Request Id in CorsEngineTracer is null [964]

$
0
0
Following traces are what you get:

```
iisexpress.exe Information: 0 : [2013-04-02T23:33:47.6530772Z] Level=Info, Kind=Begin, Category='System.Web.Http.Cors', Id=00000000-0000-0000-0000-000000000000, Operation=CorsEngine.EvaluatePolicy

iisexpress.exe Information: 0 : [2013-04-02T23:33:47.6630854Z] Level=Info, Kind=End, Category='System.Web.Http.Cors', Id=00000000-0000-0000-0000-000000000000, Message='CorsResult returned: 'IsValid: True, AllowCredentials: False, PreflightMaxAge: 5, AllowOrigin: http://localhost:28793, AllowExposedHeaders: {}, AllowHeaders:
{dataserviceversion,accept,origin}, AllowMethods: {GET}, ErrorMessages: {}'', Operation=CorsEngine.EvaluatePolicy

```

Without request Id, it is difficult to correlate the trace with a given request.

Edited Feature: Add support for Spatial Data types in OData [1010]

$
0
0
Currently, there is no support for spatial data types in Web API OData. Consider adding support for this as it makes impossible to develop any service that has to deal with spatial data.

Created Unassigned: Parameter binding information not being traced when attribute routing is used [1131]

$
0
0
__Scenario__: User would like to trace the incoming request to diagnose an issue.

__Issue__: When attribute routing is used, the traces are missing the parameter binding information.

__Possible Reason__: When "config.MapHttpAttributeRoutes()" is called, we store the action descriptors as data tokens in each of these generated routes. I am calling "config.EnableSystemDiagnosticTracing" after the above call, but I have tried calling it before and it didn't make any difference. I wasn't able to debug to the root cause, but I am guessing the problem could be timing of the wrapping of action binding tracers.

__Note__:
- Attached a standalone katana self host.
- Attached a snapshot having comparison between traces when AR is used and when not used.

Edited Unassigned: Parameter binding information not being traced when attribute routing is used [1131]

$
0
0
__Scenario__: User would like to trace the incoming request to diagnose an issue.

__Issue__: When attribute routing is used, the traces are missing the parameter binding information.

__Possible Reason__: When "config.MapHttpAttributeRoutes()" is called, we store the action descriptors as data tokens in each of these generated routes. I am calling "config.EnableSystemDiagnosticTracing" after the above call, but I have tried calling it before and it didn't make any difference. I wasn't able to debug to the root cause, but I am guessing the problem could be timing of the wrapping of action binding tracers.

__Note__:
- Attached a standalone katana self host.
- Attached a snapshot having comparison between traces when AR is used and when not used.

Commented Unassigned: Request correlation Guid should use existing one if present [1133]

$
0
0
HttpRequestMessageExtensions.GetCorrelationId() creates a new Guid and stores it as a property in the request. Tracing uses this ID to correlate all traces within a common request. ETW-based tracers are encouraged to write this same ID to System.Diagnostics.Trace.CorrelationManager.ActivityId so that ETW uses the same ID WebAPI does.

But when running web-hosted, ASP.NET effectively owns the ActivityID stored in the current CallContext and will always overwrite WebApi's anytime an 'await' is used to wait for a Task to complete. Customers have reported that exception filters and action filters get the wrong ActivityId -- it is because ASP.NET has overwritten WebApi's in the continuation of the Task that invoked the action. This happens in RTM as well as the 5.2 beta.

The advice from ASP.NET is for WebAPI (and customers) to use the existing ActivityId and not try to create one.

To fix this issue, HttpRequestMessageExtensions.GetCorrelationId should first check whether Trace.CorrelationManager.ActivityId has been set. If so, it should use it rather than Guid.NewGuid().
Comments: Added repro: Build and run repro (will need to restore packages). Use Fiddler to GET http://localhost:25533/api/values Output window from MyExceptionFilter will indicate failure. After fixing issue, Output window will indicate success.

Created Unassigned: Returning related entities when they are null. OData Web API [1134]

$
0
0
If I try to load a related entity which is null, for instance I have my schema as Carrier has many Phones and I retrieved a Phone and I want to load the Carrier but the Carrier is null (which is ok), then I go to my Container and do "LoadProperty(Phone, "Carrier")" I get an exception because on my Web API OData I have GetCarrier in my PhonesController and when it tries to return the Carrier from this Phone which is null it throws the following error:

The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; odata=minimalmetadata; streaming=true; charset=utf-8'.

With an inner exception of:

Cannot serialize a null 'entry'.

And a stack trace:

at System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteObject(Object graph, ODataMessageWriter messageWriter, ODataSerializerContext writeContext)
at System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.<>c__DisplayClassa.<WriteToStreamAsync>b__9()
at System.Threading.Tasks.TaskHelpers.RunSynchronously(Action action, CancellationToken token)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__33.MoveNext()

Is this by design or should I be handling this differently?

Edited Unassigned: Returning related entities when they are null. OData Web API [1134]

$
0
0
If I try to load a related entity which is null, for instance I have my schema as Carrier has many Phones and I retrieved a Phone and I want to load the Carrier but the Carrier is null (which is ok), then I go to my Container and do "LoadProperty(Phone, "Carrier")" I get an exception because on my Web API OData I have GetCarrier in my PhonesController and when it tries to return the Carrier from this Phone which is null it throws the following error:

```
The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; odata=minimalmetadata; streaming=true; charset=utf-8'.
```

With an inner exception of:

```
Cannot serialize a null 'entry'.
```

And a stack trace:

```
at System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteObject(Object graph, ODataMessageWriter messageWriter, ODataSerializerContext writeContext)
at System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.<>c__DisplayClassa.<WriteToStreamAsync>b__9()
at System.Threading.Tasks.TaskHelpers.RunSynchronously(Action action, CancellationToken token)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__33.MoveNext()

```
Is this by design or should I be handling this differently?

My controller has the following method:

```
public Carrier GetCarrier([FromODataUri] int key)
{
Phone phone = _context.Phones.Find(key);
if (phone == null)
{
throw ODataErrors.EntityNotFound(Request);
}

return phone.Carrier;
}
```

Edited Unassigned: Returning related entities when they are null. OData Web API [1134]

$
0
0
If I try to load a related entity which is null, for instance I have my schema as Carrier has many Phones and I retrieved a Phone and I want to load the Carrier but the Carrier is null (which is ok), then I go to my Container and do "LoadProperty(Phone, "Carrier")" I get an exception because on my Web API OData I have GetCarrier in my PhonesController and when it tries to return the Carrier from this Phone which is null it throws the following error:

```
The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; odata=minimalmetadata; streaming=true; charset=utf-8'.
```

With an inner exception of:

```
Cannot serialize a null 'entry'.
```

And a stack trace:

```
at System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteObject(Object graph, ODataMessageWriter messageWriter, ODataSerializerContext writeContext)
at System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.<>c__DisplayClassa.<WriteToStreamAsync>b__9()
at System.Threading.Tasks.TaskHelpers.RunSynchronously(Action action, CancellationToken token)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__33.MoveNext()

```
Is this by design or should I be handling this differently?

My controller has the following method:

```
public Carrier GetCarrier([FromODataUri] int key)
{
Phone phone = _context.Phones.Find(key);
if (phone == null)
{
throw ODataErrors.EntityNotFound(Request);
}

return phone.Carrier;
}
```

Or should I change my code to the following:

```
public HttpResponseMessage GetCarrier([FromODataUri] int key)
{
Phone phone = _context.Phones.Find(key);
if (phone == null)
{
throw ODataErrors.EntityNotFound(Request);
}

if(phone.Carrier == null)
return Request.CreateResponse(HttpStatusCode.OK);

return Request.CreateResponse(HttpStatusCode.OK, phone.Carrier);
}
```

By doing this I won't get the error anymore when trying to user LoadProperty even if the related entity is null. Is this the correct way of doing this?

Edited Issue: Make sure Attribute Routing and EnableCors play nicely together [954]

$
0
0
I just received a report from a user where he only uses attribute routing and because of the HTTP method route constraint that we create from the attribute, no other HTTP methods can reach the Web API pipeline. That’s problematic for the preflight requests which sends an OPTIONS.

[RoutePrefix("api/profiles")]
public class ProfilesController : ApiController
{
[System.Web.Http.HttpGet("{personId}/app/{appId}", RouteName = "ProfileApiGetPersonApp")]
public async Task<HttpResponseMessage> GetPersonApplicationProfile(Guid personId, Guid appId)

See the full context here: http://aspnetwebstack.codeplex.com/discussions/438303

Commented Unassigned: Returning related entities when they are null. OData Web API [1134]

$
0
0
If I try to load a related entity which is null, for instance I have my schema as Carrier has many Phones and I retrieved a Phone and I want to load the Carrier but the Carrier is null (which is ok), then I go to my Container and do "LoadProperty(Phone, "Carrier")" I get an exception because on my Web API OData I have GetCarrier in my PhonesController and when it tries to return the Carrier from this Phone which is null it throws the following error:

```
The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; odata=minimalmetadata; streaming=true; charset=utf-8'.
```

With an inner exception of:

```
Cannot serialize a null 'entry'.
```

And a stack trace:

```
at System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteObject(Object graph, ODataMessageWriter messageWriter, ODataSerializerContext writeContext)
at System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.<>c__DisplayClassa.<WriteToStreamAsync>b__9()
at System.Threading.Tasks.TaskHelpers.RunSynchronously(Action action, CancellationToken token)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__33.MoveNext()

```
Is this by design or should I be handling this differently?

My controller has the following method:

```
public Carrier GetCarrier([FromODataUri] int key)
{
Phone phone = _context.Phones.Find(key);
if (phone == null)
{
throw ODataErrors.EntityNotFound(Request);
}

return phone.Carrier;
}
```

Or should I change my code to the following:

```
public HttpResponseMessage GetCarrier([FromODataUri] int key)
{
Phone phone = _context.Phones.Find(key);
if (phone == null)
{
throw ODataErrors.EntityNotFound(Request);
}

if(phone.Carrier == null)
return Request.CreateResponse(HttpStatusCode.OK);

return Request.CreateResponse(HttpStatusCode.OK, phone.Carrier);
}
```

By doing this I won't get the error anymore when trying to user LoadProperty even if the related entity is null. Is this the correct way of doing this?

Comments: There is no representation for null entities in OData. complex types with null values on the other hand can be represented in the payload. If the entity that you are returning is null, you should instead return a 404. So, your action should be, ``` public HttpResponseMessage GetCarrier([FromODataUri] int key) { Phone phone = _context.Phones.Find(key); if (phone == null) { throw ODataErrors.EntityNotFound(Request); } if(phone.Carrier == null) { throw ODataErrors.EntityNotFound(Request); } return Request.CreateResponse(HttpStatusCode.OK, phone.Carrier); } ```

Closed Issue: OData $expand broken [1098]

$
0
0
(Updated: added the EntitySetController for reference)

Using the nightly build as of 6/20. $expand and $select seems to be broken. Given this simple set of models (exposed with a simple EntitySetController<EntityA, int> returning data from an in-memory array):

```
public class EntityA
{
public int Id { get; set; }
public string Name { get; set; }
public virtual EntityB EntityB { get; set; }
}

public class EntityB
{
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<EntityA> EntityA { get; set; }
}

public class EntityAController : EntitySetController<EntityA, int>
{
private static readonly List<EntityA> entities;
static EntityAController()
{
entities= new List<EntityA>
{
new EntityA
{
Id = 1,
Name = "EntityA 1",
},
new EntityA
{
Id = 2,
Name = "EntityA 2",
},
};
var i = 1;
foreach (var entity in entities)
{
entity.EntityB = new EntityB
{
Id = i,
Name = String.Format("EntityB {0}", i),
EntityA= new List<EntityA> { entity },
};
i++;
}
}

protected override EntityA GetEntityByKey(int key)
{
return entities.FirstOrDefault(_ => GetKey(_) == key);
}

protected override int GetKey(EntityA entity)
{
return entity.Id;
}

[Queryable(AllowedQueryOptions = AllowedQueryOptions.All)]
public override IQueryable<EntityA> Get()
{
return entities.AsQueryable();
}
}
```

Example 1:
/EntityA?$expand=EntityB

What I expect: list of EntityAs, including values for Id, Name, EntityB/Id, EntityB/Name.
What I get: list of EntityAs, only values for EntityB/Id, EntityB/Name

Using $select as a workaround to get those missing fields doesn't work either:

Example 2:
/EntityA?$expand=EntityB&$select=Id,Name,EntityB/Id,EntityB/Name
What I expect: (same as Example 1)
What I get: (same as Example 1)

Commented Unassigned: Returning related entities when they are null. OData Web API [1134]

$
0
0
If I try to load a related entity which is null, for instance I have my schema as Carrier has many Phones and I retrieved a Phone and I want to load the Carrier but the Carrier is null (which is ok), then I go to my Container and do "LoadProperty(Phone, "Carrier")" I get an exception because on my Web API OData I have GetCarrier in my PhonesController and when it tries to return the Carrier from this Phone which is null it throws the following error:

```
The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; odata=minimalmetadata; streaming=true; charset=utf-8'.
```

With an inner exception of:

```
Cannot serialize a null 'entry'.
```

And a stack trace:

```
at System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteObject(Object graph, ODataMessageWriter messageWriter, ODataSerializerContext writeContext)
at System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.<>c__DisplayClassa.<WriteToStreamAsync>b__9()
at System.Threading.Tasks.TaskHelpers.RunSynchronously(Action action, CancellationToken token)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__33.MoveNext()

```
Is this by design or should I be handling this differently?

My controller has the following method:

```
public Carrier GetCarrier([FromODataUri] int key)
{
Phone phone = _context.Phones.Find(key);
if (phone == null)
{
throw ODataErrors.EntityNotFound(Request);
}

return phone.Carrier;
}
```

Or should I change my code to the following:

```
public HttpResponseMessage GetCarrier([FromODataUri] int key)
{
Phone phone = _context.Phones.Find(key);
if (phone == null)
{
throw ODataErrors.EntityNotFound(Request);
}

if(phone.Carrier == null)
return Request.CreateResponse(HttpStatusCode.OK);

return Request.CreateResponse(HttpStatusCode.OK, phone.Carrier);
}
```

By doing this I won't get the error anymore when trying to user LoadProperty even if the related entity is null. Is this the correct way of doing this?

Comments: But when consuming in a .NET client if I try to load that related property it gives an error from the server that it cannot deserialize a null entity. I find it much more friendly to return an empty 200 (OK) from the server and the property on the client will stay null since I didn't send anything, than sending a 404 and in my client having to wrap the LoadProperty method with a try..catch. Am I wrong or the client's DataServiceContext should process this on its own?

Edited Unassigned: Post error: Either BinaryRead, Form, Files, or InputStream was accessed before the internal storage [1132]

$
0
0
See full [question in Stackoverflow](http://stackoverflow.com/questions/17602845/post-error-either-binaryread-form-files-or-inputstream-was-accessed-before-t)

After performing the downgrade webapi, it worked! But now without support for $expand and $select.

It seems that [this commit](https://aspnetwebstack.codeplex.com/SourceControl/changeset/0678d3e314c08403e1c9584cd08846b045ad5f5f) generated this error. (Thanks [JimmiTh](http://chat.stackoverflow.com/users/1169696/jimmith) and [Kiran Challa](http://chat.stackoverflow.com/users/1184056/kiran-challa))

Commented Issue: Action selection requires a default value on a parameter even when the parameter is marked as optional [966]

$
0
0
This is especially an issue for attribute routing:

[HttpGet("{id?}")]
public string Get(string id) { }

doesn't work unless you add a default value

[HttpGet("{id?}")]
public string Get(string id = null) { }
Comments: Fixed: https://aspnetwebstack.codeplex.com/SourceControl/changeset/50bb37c482dfc7e0d1680ffef49e6beed0e5c768

Edited Issue: Action selection requires a default value on a parameter even when the parameter is marked as optional [966]

$
0
0
This is especially an issue for attribute routing:

[HttpGet("{id?}")]
public string Get(string id) { }

doesn't work unless you add a default value

[HttpGet("{id?}")]
public string Get(string id = null) { }

Commented Issue: Razor V2 Bug:Url Resolution Fails if you have Html Comment with Quotation or Apostrophe [933]

$
0
0
During discussing a thread in ASP.NET MVC forums, found a bug in Razor V2 in which the auto url resolution(~) will not work if you have an html comment with quotation or apostrophe before the url resolution(~) tag. Here is an quick example,
``` Html
<!-- '" -->
<img src="~/images/submit.png" />
```

See this thread,
[http://forums.asp.net/t/1892597.aspx/1?Using+UrlHelper+Content](http://forums.asp.net/t/1892597.aspx/1?Using+UrlHelper+Content)
Comments: Finally found the real duplicate it was 710. 710 already fixes this issue, but I added tests for this specific scenario as well.
Viewing all 7215 articles
Browse latest View live




Latest Images