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

Edited Issue: Microsoft.Web.Helpers.Facebook - LikeBox dont work [286]

$
0
0
LikeBox function use "http://www.facebook.com/plugins/recommendations.php" instead "likebox.php"

Edited Issue: Webgrid and sorting on a column with null values (MVC3) [138]

$
0
0
The problem is based on the following example (borrowed from http://stackoverflow.com/questions/2290436/linq-orderby-breaks-with-navigation-property-being-null) :

table Users -> has basic user info including a userid and a departmentid (int)

table Departments -> basic department info including deptid


"Not every user has a department"


var userQuery = from u in grp.Users

select u;

userQuery = userQuery.OrderBy(u => u.Department.Name);


If Department is equal to null, Linq will die with an null reference exception.
We can protect against that by testing on null:
userQuery = userQuery.OrderBy(u => (u.Department != null) ? u.Department.Name : String.Empty



The code used in the webgrid helper does not test on null, resulting for this specific case in a null reference exception.

The code sample underneath is a possible solution without to much changing the original MVC workflow.
Attention I did not test this code for each possible case, it was just done to understand the problem and to be able to post a meaningfull bug request. In our solution, we actually deactivated the sort possibility on this column because we didn't want to create ourselves a fork of the MVC project, we use only the official releases of MVC.


- WebGrid.cs: private string GetTableBodyHtml(IEnumerable<WebGridColumn> columns, string rowStyle, string alternatingRowStyle, string selectedRowStyle)
In this method the rows with data are retrieved from the datasource so that the underlying table can be build.

When accessing the property Rows, we are transferred to the file
- WebGridDataSource.cs: public IList<WebGridRow> GetRows(SortInfo sortInfo, int pageIndex).
- The creation of the sorting Linq expression is done in the method "private IQueryable<dynamic> Sort(IQueryable<dynamic> data, Type elementType, SortInfo sort)"

private IQueryable<dynamic> Sort(IQueryable<dynamic> data, Type elementType, SortInfo sort) {
Debug.Assert(data != null);

if (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(elementType)) {
// IDynamicMetaObjectProvider properties are only available through a runtime binder, so we
// must build a custom LINQ expression for getting the dynamic property value.
// Lambda: o => o.Property (where Property is obtained by runtime binder)
// NOTE: lambda must not use internals otherwise this will fail in partial trust when Helpers assembly is in GAC
var binder = RB.Binder.GetMember(RB.CSharpBinderFlags.None, sort.SortColumn, typeof(WebGrid), new RB.CSharpArgumentInfo[] {
RB.CSharpArgumentInfo.Create(RB.CSharpArgumentInfoFlags.None, null) });
var param = Expression.Parameter(typeof(IDynamicMetaObjectProvider), "o");
var getter = Expression.Dynamic(binder, typeof(object), param);
return SortGenericExpression<IDynamicMetaObjectProvider, object>(data, getter, param, sort.SortDirection);
}
else {
// The IQueryable<dynamic> data source is cast as IQueryable<object> at runtime. We must call
// SortGenericExpression using reflection so that the LINQ expressions use the actual element type.
// Lambda: o => o.Property[.NavigationProperty,etc]
var param = Expression.Parameter(elementType, "o");
Expression member = param;
var type = elementType;
var sorts = sort.SortColumn.Split('.');

//**********************************************************************************************************************
List<Expression> conditionNullExpressions = new List<Expression>(sorts.Length);
Expression conditionNull = null;
//**********************************************************************************************************************

foreach (var name in sorts)
{
PropertyInfo prop = type.GetProperty(name);
if (prop == null) {
// no-op in case navigation property came from querystring (falls back to default sort)
if ((DefaultSort != null) && !sort.Equals(DefaultSort) && !String.IsNullOrEmpty(DefaultSort.SortColumn)) {
return Sort(data, elementType, DefaultSort);
}
return data;
}
member = Expression.Property(member, prop);

//**********************************************************************************************************************
// protect agains nulls
// see example: userQuery = userQuery.OrderBy(u => (u.Department != null) ? u.Department.Name : String.Empty
conditionNull = Expression.NotEqual(member, Expression.Constant(null));
conditionNullExpressions.Add(conditionNull);
//**********************************************************************************************************************

type = prop.PropertyType;
}

//**********************************************************************************************************************
// delete the last added condition on null, not needed because last property
if (conditionNull != null)
conditionNullExpressions.Remove(conditionNull);

if (conditionNullExpressions.Count > 0)
{
conditionNullExpressions.Reverse();
Expression buildCond = null;
foreach (Expression expression in conditionNullExpressions)
{
buildCond = Expression.Condition(expression, buildCond ?? member,
Expression.Constant("zzzzzzzzz"));
}
member = buildCond;
}
//**********************************************************************************************************************

MethodInfo m = this.GetType().GetMethod("SortGenericExpression", BindingFlags.Static | BindingFlags.NonPublic);
m = m.MakeGenericMethod(elementType, member.Type);
return (IQueryable<dynamic>)m.Invoke(null, new object[] { data, member, param, sort.SortDirection });
}
}

Regards,

PS: in attachment the WebGridDataSource codefile.

Edited Issue: Model-binding collection fails when non-collection property shares a prefix [832]

$
0
0
Given a collection property named "foos" and another property named "foosBar" on an object being model-bound, because of the implementation of the PrefixContainer (specifically the IsPrefixMatch method), if "foosBar" is on a boundary checked by Array.BinarySearch, the algorithm will miss all the collection properties, and the collection will be null after model-binding completes.

I've included failing test in pull request [4032](http://aspnetwebstack.codeplex.com/SourceControl/network/forks/bmsullivan/prefixcontainertests/contribution/4032). I'm honestly not sure how to fix this without breaking something else or significantly impacting model-binding performance.

Edited Issue: Unable to deserialize edm:Time property [975]

$
0
0
I have an working OData service, but as soon as a I add a property of type TimeSpan, I have trouble POSTing to it. The $metadata shows the type as Edm:Time as I would expect. And Fiddler shows the property in question having a value of "00:05:00" which seems correct.

Edited Issue: Collection property deserialization doesn't work [422]

$
0
0
When send back with collection property data in entity payload, it reports error: no collection property support yet.

> System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.Deserialization.ODataEntryDeserializer.ConvertCollectionValue(Microsoft.Data.OData.ODataCollectionValue collection, Microsoft.Data.Edm.IEdmTypeReference propertyType, System.Web.Http.OData.Formatter.Deserialization.ODataDeserializerProvider deserializerProvider, System.Web.Http.OData.Formatter.Deserialization.ODataDeserializerContext readContext) Line 288 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.Deserialization.ODataEntryDeserializer.ConvertValue(object oDataValue, ref Microsoft.Data.Edm.IEdmTypeReference propertyType, System.Web.Http.OData.Formatter.Deserialization.ODataDeserializerProvider deserializerProvider, System.Web.Http.OData.Formatter.Deserialization.ODataDeserializerContext readContext, out Microsoft.Data.Edm.EdmTypeKind typeKind) Line 152 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.Deserialization.ODataEntryDeserializer.ApplyProperty(Microsoft.Data.OData.ODataProperty property, Microsoft.Data.Edm.IEdmStructuredTypeReference resourceType, object resource, System.Web.Http.OData.Formatter.Deserialization.ODataDeserializerProvider deserializerProvider, System.Web.Http.OData.Formatter.Deserialization.ODataDeserializerContext readContext) Line 107 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.Deserialization.ODataEntityDeserializer.ApplyValueProperties(Microsoft.Data.OData.ODataEntry entry, Microsoft.Data.Edm.IEdmStructuredTypeReference entityType, object entityResource, System.Web.Http.OData.Formatter.Deserialization.ODataDeserializerContext readContext) Line 308 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.Deserialization.ODataEntityDeserializer.ApplyEntityProperties(Microsoft.Data.OData.ODataEntry entry, System.Web.Http.OData.Formatter.Deserialization.ODataEntryAnnotation entryAnnotation, System.Web.Http.OData.Formatter.Deserialization.ODataDeserializerContext readContext) Line 224 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.Deserialization.ODataEntityDeserializer.ReadInline(Microsoft.Data.OData.ODataEntry entry, System.Web.Http.OData.Formatter.Deserialization.ODataDeserializerContext readContext) Line 57 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.Deserialization.ODataEntityDeserializer.Read(Microsoft.Data.OData.ODataMessageReader messageReader, System.Web.Http.OData.Formatter.Deserialization.ODataDeserializerContext readContext) Line 41 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.ReadFromStreamAsync(System.Type type, System.IO.Stream readStream, System.Net.Http.HttpContent content, System.Net.Http.Formatting.IFormatterLogger formatterLogger) Line 191 C#
System.Net.Http.Formatting.dll!System.Net.Http.HttpContentExtensions.ReadAsAsync<object>.AnonymousMethod__0(System.IO.Stream stream)
System.Net.Http.Formatting.dll!System.Threading.Tasks.TaskHelpersExtensions.Then<System.__Canon,System.__Canon>.AnonymousMethod__40(System.Threading.Tasks.Task<System.__Canon> t)
System.Net.Http.Formatting.dll!System.Threading.Tasks.TaskHelpersExtensions.ThenImpl<System.Threading.Tasks.Task<System.IO.Stream>,object>(System.Threading.Tasks.Task<System.IO.Stream> task, System.Func<System.Threading.Tasks.Task<System.IO.Stream>,System.Threading.Tasks.Task<object>> continuation, System.Threading.CancellationToken cancellationToken, bool runSynchronously)
System.Net.Http.Formatting.dll!System.Net.Http.HttpContentExtensions.ReadAsAsync<object>(System.Net.Http.HttpContent content, System.Type type, System.Collections.Generic.IEnumerable<System.Net.Http.Formatting.MediaTypeFormatter> formatters, System.Net.Http.Formatting.IFormatterLogger formatterLogger)
System.Net.Http.Formatting.dll!System.Net.Http.HttpContentExtensions.ReadAsAsync(System.Net.Http.HttpContent content, System.Type type, System.Collections.Generic.IEnumerable<System.Net.Http.Formatting.MediaTypeFormatter> formatters, System.Net.Http.Formatting.IFormatterLogger formatterLogger)
System.Web.Http.dll!System.Web.Http.ModelBinding.FormatterParameterBinding.ExecuteBindingAsync(System.Web.Http.Metadata.ModelMetadataProvider metadataProvider, System.Web.Http.Controllers.HttpActionContext actionContext, System.Threading.CancellationToken cancellationToken)
System.Web.Http.dll!System.Web.Http.Controllers.HttpActionBinding.ExecuteBindingAsync.AnonymousMethod__0(System.Web.Http.Controllers.HttpParameterBinding parameterBinder)
System.Core.dll!System.Linq.Enumerable.WhereSelectArrayIterator<System.__Canon,System.__Canon>.MoveNext()
System.Web.Http.dll!System.Threading.Tasks.TaskHelpers.IterateImpl(System.Collections.Generic.IEnumerator<System.Threading.Tasks.Task> enumerator, System.Threading.CancellationToken cancellationToken)
System.Web.Http.dll!System.Threading.Tasks.TaskHelpers.Iterate(System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task> asyncIterator, System.Threading.CancellationToken cancellationToken, bool disposeEnumerator)
System.Web.Http.dll!System.Web.Http.Controllers.HttpActionBinding.ExecuteBindingAsync(System.Web.Http.Controllers.HttpActionContext actionContext, System.Threading.CancellationToken cancellationToken)
System.Web.Http.dll!System.Web.Http.ApiController.ExecuteAsync.AnonymousMethod__0()
System.Web.Http.dll!System.Web.Http.ApiController.ExecuteAsync(System.Web.Http.Controllers.HttpControllerContext controllerContext, System.Threading.CancellationToken cancellationToken)
System.Web.Http.dll!System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
System.Net.Http.dll!System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
System.Web.Http.dll!System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
System.Web.Http.dll!System.Web.Http.HttpServer.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
System.Web.Http.SelfHost.dll!System.Web.Http.SelfHost.HttpSelfHostServer.ProcessRequestContext(System.Web.Http.SelfHost.HttpSelfHostServer.ChannelContext channelContext, System.ServiceModel.Channels.RequestContext requestContext)
System.Web.Http.SelfHost.dll!System.Web.Http.SelfHost.HttpSelfHostServer.ReceiveRequestContextComplete(System.IAsyncResult result)
System.ServiceModel.Internals.dll!System.Runtime.AsyncResult.Complete(bool completedSynchronously)
System.ServiceModel.Internals.dll!System.Runtime.InputQueue<System.ServiceModel.Channels.RequestContext>.AsyncQueueReader.Set(System.Runtime.InputQueue<System.ServiceModel.Channels.RequestContext>.Item item)
System.ServiceModel.Internals.dll!System.Runtime.InputQueue<System.ServiceModel.Channels.RequestContext>.EnqueueAndDispatch(System.Runtime.InputQueue<System.ServiceModel.Channels.RequestContext>.Item item, bool canDispatchOnThisThread)
System.ServiceModel.Internals.dll!System.Runtime.InputQueue<System.ServiceModel.Channels.RequestContext>.EnqueueAndDispatch(System.ServiceModel.Channels.RequestContext item, System.Action dequeuedCallback, bool canDispatchOnThisThread)
System.ServiceModel.dll!System.ServiceModel.Channels.SingletonChannelAcceptor<System.ServiceModel.Channels.IReplyChannel,System.ServiceModel.Channels.ReplyChannel,System.ServiceModel.Channels.RequestContext>.Enqueue(System.ServiceModel.Channels.RequestContext item, System.Action dequeuedCallback, bool canDispatchOnThisThread)
System.ServiceModel.dll!System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult.CompleteParseAndEnqueue(System.IAsyncResult result)
System.ServiceModel.dll!System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult.HandleParseIncomingMessage(System.IAsyncResult result)
System.ServiceModel.Internals.dll!System.Runtime.AsyncResult.AsyncCompletionWrapperCallback(System.IAsyncResult result)
System.ServiceModel.Internals.dll!System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(System.IAsyncResult result)
System.ServiceModel.Internals.dll!System.Runtime.AsyncResult.Complete(bool completedSynchronously)
System.ServiceModel.dll!System.ServiceModel.Channels.HttpInput.ParseMessageAsyncResult.OnRead(System.IAsyncResult result)
System.ServiceModel.Internals.dll!System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(System.IAsyncResult result)
System.dll!System.Net.LazyAsyncResult.Complete(System.IntPtr userToken)
System.dll!System.Net.HttpRequestStream.HttpRequestStreamAsyncResult.IOCompleted(System.Net.HttpRequestStream.HttpRequestStreamAsyncResult asyncResult, uint errorCode, uint numBytes)
mscorlib.dll!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* pOVERLAP)

The code causing the problem is:
Contract.Assert(propertyKind != EdmTypeKind.Primitive, "no collection property support yet.");

We should remove the assert code as we are support collection property now.

Edited Issue: Unable to deserialize edm:Time property [975]

$
0
0
I have an working OData service, but as soon as a I add a property of type TimeSpan, I have trouble POSTing to it. The $metadata shows the type as Edm:Time as I would expect. And Fiddler shows the property in question having a value of "00:05:00" which seems correct.

Edited Issue: [Cors] RequestMessageHandlerTracer is not executed for OPTIONS preflight request. [962]

$
0
0
__Repro__
Setup a CORS enable web site and write a customized trace writer like this:

```
public class CustomTraceWriter : SystemDiagnosticsTraceWriter
{
public override void Trace(
HttpRequestMessage request,
string category,
TraceLevel level,
Action<TraceRecord> traceAction)
{
if (category == "System.Web.Http.Request")
{
base.Trace(request, category, level, traceAction);
}
}
}
```

Trigger a "complex" request with involving preflight OPTIONS request.

Observe the output window in Visual Studio, you will see log like: (noises are removed)
```
iisexpress.exe Information: 0 : Request, Method=GET, Url=http://localhost:27032/odata/Movies?$top=20, Message='http://localhost:27032/odata/Movies?$top=20'
iisexpress.exe Information: 0 : Response, Status=200 (OK), Method=GET, Url=http://localhost:27032/odata/Movies?$top=20, Message='Content-type='application/json; charset=utf-8', content-length=unknown'
```

The OPTIONS request is not logged.

__Root__

CorsMessageHandler is added at end of message handler pipeline but before RequestMessageHandlerTracer. It is because default HttpConfiguration initializer execute ITraceManager initialization after EnableCors.

__Customer Impact__

Some customers relies on the tracer writer to audit all request and response inbound and outbound. This issue preventing them from logging OPTIONS request/response in CORS scenario.

Edited Issue: Add CreateResponse overload that only takes T for body [960]

$
0
0
Currently there is an overload that takes HttpStatusCode and T but in many cases HttpStatusCode.OK is the code and in those cases it would be easier just to be able to pass in T.

It would also be useful to have additional CreateErrorResponse for server error, client error, etc.



Edited Issue: Stack overflow if GetControllerMapping called before 1st request [938]

$
0
0
If tracing is enabled and DefaultHttpControllerSelector.GetControllerMapping() is called before the first request has been processed, the MessageHandler pipeline will be corrupted.
The TraceManager.Initialize() code is idempotent for MessageHandlers only after the pipeline has been initialized at the first request. If called before the pipeline has been initialized, it will redundantly wrap MessageHandlerTracer's around other MessageHandlerTracers.
The net result of this is a corrupt pipeline of MessageHandlers that will cause stack overflow at first request.

The TraceManager.Initialize() needs to protect itself when it finds MessageHandlerTracer's already installed in HttpConfiguration.MessageHandlers

Edited Issue: Flow the TimedOutToken and ClientDisconnectedToken [858]

$
0
0
With [this commit](http://aspnetwebstack.codeplex.com/SourceControl/changeset/c18dbd8306a2), it's now possible to flow the following two CancellationToken objects through the ASP.NET Web API pipeline under ASP.NET host:

```
public override Task ProcessRequestAsync(HttpContext context) {

CancellationTokenSource cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(
context.Request.TimedOutToken,
context.Response.ClientDisconnectedToken);

//...

}
```

Edited Issue: Add extension method to HttpRequestMessage so that user can find out whether the request is coming from Local box [833]

$
0
0
Internally, we have save the IsLocal result in the HttpRequestMessage's property bag. Here are where we populate them.

SelfHost: HttpSelfHostServer.ProcessRequestContext()

// Add information about whether the request is local or not
request.Properties.Add(HttpPropertyKeys.IsLocalKey, new Lazy<bool>(() => IsLocal(requestContext.RequestMessage)));

WebHost: HttpControllerHandler.ConvertRequest()
// Add information about whether the request is local or not
request.Properties.Add(HttpPropertyKeys.IsLocalKey, new Lazy<bool>(() => requestBase.IsLocal));

Here is where it is consumed:

We needed this information to figure out whether to include error details or not.

We could add an extension method on the http request message to help user figure out if the request is local or not. So user can write code like the following:

Request.IsLocal();


Edited Issue: Tracing formatters should expose the inner formatter [580]

$
0
0
This is required by OData. A workaround was implemented that also needs to be removed.

Edited Issue: Provide API to retrieve wrapped services [382]

$
0
0
The tracing layer wraps a trace-aware object around major services and formatters. Apps that need to downcast a service or formatter need a way to ask for the inner object instance.

I recommend we design for a general purpose wrapping API, not just tracing. Consider something like IWrappable<T> and Wrappable.Unwrap<T>(object). Make trace wrappers implement this and make MediaTypeFormatterCollection aware to use it.

Also fix OData code to use this when asking for the model from the ODataMediaTypeFormatter.

Edited Issue: HttpConfiguration.ShouldIncludeErrorDetail should be public [361]

$
0
0
This would allow users to easily decide in their action whether or not they should send error detail for custom HttpErrors.

Edited Issue: Key to the HttpError dictionary shall be public [187]

$
0
0
Following keys are private:
private const string MessageKey = "Message";
private const string MessageDetailKey = "MessageDetail";
private const string ModelStateKey = "ModelState";
private const string ExceptionMessageKey = "ExceptionMessage";
private const string ExceptionTypeKey = "ExceptionType";
private const string StackTraceKey = "StackTrace";
private const string InnerExceptionKey = "InnerException";

It makes it difficult for client to extract error information directly. If the string is hard coded and in the future the keys are changed, then maintaining cost is introduced.

Closed Issue: ReadAsMultipartAsync returns result before all files have been written [282]

$
0
0
We trying to perform validation of the files which have been processed by ReadAsMultipartAsync, but sometimes on the attempts to open file for reading IOException is throwing, like this:

The process cannot access the file 'C:\\Windows\\TEMP\\BodyPart_abd1efe9-b1d5-4956-b79b-0519837e9377' because it is being used by another process.","StackTrace":" at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.IO.File.OpenRead(String path)

at ...

at System.ComponentModel.DataAnnotations.ValidationAttribute.GetValidationResult(Object value, ValidationContext validationContext)
at System.Web.Http.Validation.Validators.DataAnnotationsModelValidator.Validate(ModelMetadata metadata, Object container)
at System.Web.Http.Validation.DefaultBodyModelValidator.ShallowValidate(ModelMetadata metadata, ValidationContext validationContext, Object container)
at System.Web.Http.Validation.DefaultBodyModelValidator.ValidateProperties(ModelMetadata metadata, ValidationContext validationContext)
at System.Web.Http.Validation.DefaultBodyModelValidator.ValidateNodeAndChildren(ModelMetadata metadata, ValidationContext validationContext, Object container)
at System.Web.Http.ModelBinding.FormatterParameterBinding.<>c__DisplayClass1.<ExecuteBindingAsync>b__0(Object model)
at System.Threading.Tasks.TaskHelpersExtensions.<>c__DisplayClass40.<ToAsyncVoidTask>b__3f()
at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)

Example code:

var provider = new MultipartFormDataStreamProvider(_uploadPath);
return content.ReadAsMultipartAsync(provider)
.ContinueWith(multiPartTask =>
{
if (multiPartTask.IsCanceled || multiPartTask.IsFaulted)
{
Trace.TraceError("Failed multipart message reading: {0}", multiPartTask.Exception);
return null;
}

// ...
// use files in the task Result
// using (var fileStream = File.OpenRead(fileName)) {}

return null;
});

When processing time is delayed by something, eg Thread.Sleep, count of the io exceptions decreased, but it's not workaround.
How can we get access to the files, when it's actually written?

Comments: We are closing this issue because the root cause was found to be in framework code. A separate bug has been opened against an external partner team, and this issue will be tracked there. The changeset: http://aspnetwebstack.codeplex.com/SourceControl/changeset/changes/452b8e1dfa40 reverts an attempted fix where we used FileOptions.WriteThrough to ensure it was not a race between the File Cache and FileStream code. But WriteThrough did not address the core bug and caused a performance degradation. Impact on user code is this: if you upload a file with MultipartFormDataContent and read it on the server using MultiPartDataStreamProvider, the underlying file on the server may not be fully closed after the ReadAsMultipartAsync completes. There is a small window where native code may still be releasing file resources on another thread. The impact is that a File.Delete or File.OpenRead done on that file immediately after the async read may fail with an IOException ("file is in use by another process"). We observed about 0.3% failure rate in high-load situations. The only known work-around is to put a try/catch around those operations, delay a short time if an IOException occurs, and retry. A 50ms delay generally works, but allowing for multiple retries is recommended. This allows the native thread to finish releasing its resources. In our stress labs, this catch-delay-and-retry algorithm always succeeds. See: https://aspnetwebstack.codeplex.com/workitem/176

Closed Issue: Add CreateResponse overload that only takes T for body [960]

$
0
0
Currently there is an overload that takes HttpStatusCode and T but in many cases HttpStatusCode.OK is the code and in those cases it would be easier just to be able to pass in T.

It would also be useful to have additional CreateErrorResponse for server error, client error, etc.


Comments: Verified.

Commented Unassigned: [WebApiOnOwin]Formatter write exceptions generated HttpError responses are sent in chunked encoding format [998]

$
0
0
When there are exceptions during a formatter's write to stream, I am seeing that the HttpError responses is being sent in chunked encoding format.

I noticed that this HttpError response behavior is correct(i.e non-chunked) when its generated for exceptions happening at other layers (for example, inside an action).

Attached a standalone repro.

__NOTE__: this bug is different from #993 in sense that the current scenario has a body in it, where as #993 does not have one.
Comments: We should definitely fix this.

Closed Issue: Content negotiation returns 406 on missing accept header [353]

$
0
0
Using DefaultContentNegotiator (at least with excludematchontype = true) returns a 406 for all requests without an accept header.

Http spec says that a missing accept header means the client will accept anything, i.e., everything is acceptable.

Web api should respect the spec.
Comments: Verified.

Closed Issue: WebAPI should return a 415 instead of a 500 when it can't find a formatter that matches the request media type [268]

$
0
0
We currently get:

<Error><Message>An exception has occurred.</Message><ExceptionMessage>No MediaTypeFormatter is available to read an object of type 'ZumoAppInput' from content with media type 'application/json'.</ExceptionMessage><ExceptionType>System.InvalidOperationException</ExceptionType><StackTrace> at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger)
at System.Net.Http.HttpContentExtensions.ReadAsAsync(HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger)
at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger)
at System.Web.Http.ModelBinding.FormatterParameterBinding.ExecuteBindingAsync(ModelMetadataProvider metadataProvider, HttpActionContext actionContext, CancellationToken cancellationToken)
at System.Web.Http.Controllers.HttpActionBinding.<>c__DisplayClass1.<ExecuteBindingAsync>b__0(HttpParameterBinding parameterBinder)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Threading.Tasks.TaskHelpers.IterateImpl(IEnumerator`1 enumerator, CancellationToken cancellationToken)</StackTrace></Error>
Comments: Verified.
Viewing all 7215 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>