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

Commented Unassigned: Exception inside PushStreamContent won't be caught by ExceptionFilterAttribute? [1089]

$
0
0
Hi,

I'm using PushStreamContent in asp.net web api to stream data to the client, I have derived from ExceptionFilterAttribute to capture all the exceptions and return standard HttpError to client. However,
I found that exception thrown inside PushStreamContent won't be caught by ExceptionFilterAttribute, it will return a "text/html" error message to client.
Below is the sample code:

response.Content = new PushStreamContent(
async (outputStream, httpContent, transportContext) =>
{
try
{
// do something and throw exception here

}
catch (Exception ex)
{
throw;
}
finally
{
outputStream.Close();
}
});
Comments: Then is there any best practice to handle exceptions from PushStreamContent? For example, client use code below to read the stream using (Stream stream = response.GetResponseStream()) { int count; while ((count = stream.Read(data, totalCount, data.Length - totalCount)) > 0) { totalCount += count; } } However, client will read the exception content as normal stream which is not expected.

Reopened Unassigned: Exception inside PushStreamContent won't be caught by ExceptionFilterAttribute? [1089]

$
0
0
Hi,

I'm using PushStreamContent in asp.net web api to stream data to the client, I have derived from ExceptionFilterAttribute to capture all the exceptions and return standard HttpError to client. However,
I found that exception thrown inside PushStreamContent won't be caught by ExceptionFilterAttribute, it will return a "text/html" error message to client.
Below is the sample code:

response.Content = new PushStreamContent(
async (outputStream, httpContent, transportContext) =>
{
try
{
// do something and throw exception here

}
catch (Exception ex)
{
throw;
}
finally
{
outputStream.Close();
}
});

Edited Unassigned: Exception inside PushStreamContent won't be caught by ExceptionFilterAttribute? [1089]

$
0
0
Hi,

I'm using PushStreamContent in asp.net web api to stream data to the client, I have derived from ExceptionFilterAttribute to capture all the exceptions and return standard HttpError to client. However,
I found that exception thrown inside PushStreamContent won't be caught by ExceptionFilterAttribute, it will return a "text/html" error message to client.
Below is the sample code:

response.Content = new PushStreamContent(
async (outputStream, httpContent, transportContext) =>
{
try
{
// do something and throw exception here

}
catch (Exception ex)
{
throw;
}
finally
{
outputStream.Close();
}
});

Commented Issue: Ajax.BeginForm() not sending submit button's name/value [567]

$
0
0
There are certain circumstances when using Ajax.BeginForm() and the underlying jquery.unobtrusive-ajax.js script that the name/value of the submit button is not posted to the server.

See StackOverflow question http://stackoverflow.com/questions/11737779/ajax-beginform-not-sending-submit-buttons-name-value.

Attached is the file edited by myself that fixes the bug
Comments: Hi Very busy at work at the moment and need to get Git up and running. Will hopefully get it done this week. Thanks Dave

Commented Issue: UpForGrabs: Web Api ModelState validation is ignoring the DisplayAttribute [744]

$
0
0
Given a model with these data annotations:

public class Example
{
[Required]
[Display(Name = "Activity response")]
public string ActivityResponse { get; set; }
}

I would expect the model state error message to be "The Activity response field is required." Instead it is "The ActivityResponse field is required."
Comments: Any ideas for a temp fix for this? This is currently game breaking for us as we can't accurately tell our users which field(s) didn't pass server side model validation.

Created Unassigned: Add foreign key information to the associations in the $metadata document [1094]

$
0
0
When there is an entity in a model that has an entity that explicitly exposes the foreign key of an association to another entity, make that information visible and available in the $metadata document.

For example:

```
<EntityType Name="Customer">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation" Name="Id" Type="Edm.Int32" Nullable="false" p6:StoreGeneratedPattern="Identity"/>
<Property Name="Name" Type="Edm.String" MaxLength="Max" FixedLength="false" Unicode="true"/>
<NavigationProperty Name="Orders" Relationship="WcfDataServicesForeignKey.Customer_Orders" ToRole="Customer_Orders_Target" FromRole="Customer_Orders_Source"/>
</EntityType>
<EntityType Name="Order">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation" Name="Id" Type="Edm.Int32" Nullable="false" p6:StoreGeneratedPattern="Identity"/>
<Property Name="CustomerId" Type="Edm.Int32" Nullable="false"/>
<Property Name="Purchased" Type="Edm.DateTime" Nullable="false"/>
<Property Name="Total" Type="Edm.Double" Nullable="false"/>
</EntityType>
<Association Name="Customer_Orders">
<End Type="WcfDataServicesForeignKey.Customer" Role="Customer_Orders_Source" Multiplicity="1">
<OnDelete Action="Cascade"/>
</End>
<End Type="WcfDataServicesForeignKey.Order" Role="Customer_Orders_Target" Multiplicity="*"/>
<ReferentialConstraint>
<Principal Role="Customer_Orders_Source">
<PropertyRef Name="Id"/>
</Principal>
<Dependent Role="Customer_Orders_Target">
<PropertyRef Name="CustomerId"/>
</Dependent>
</ReferentialConstraint>
</Association>
```

Edited Unassigned: Add foreign key information to the associations in the $metadata document [1094]

$
0
0
When there is an entity in a model that has an entity that explicitly exposes the foreign key of an association to another entity, make that information visible and available in the $metadata document.

For example:

```
<EntityType Name="Customer">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation" Name="Id" Type="Edm.Int32" Nullable="false" p6:StoreGeneratedPattern="Identity"/>
<Property Name="Name" Type="Edm.String" MaxLength="Max" FixedLength="false" Unicode="true"/>
<NavigationProperty Name="Orders" Relationship="WcfDataServicesForeignKey.Customer_Orders" ToRole="Customer_Orders_Target" FromRole="Customer_Orders_Source"/>
</EntityType>
<EntityType Name="Order">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation" Name="Id" Type="Edm.Int32" Nullable="false" p6:StoreGeneratedPattern="Identity"/>
<Property Name="CustomerId" Type="Edm.Int32" Nullable="false"/>
<Property Name="Purchased" Type="Edm.DateTime" Nullable="false"/>
<Property Name="Total" Type="Edm.Double" Nullable="false"/>
</EntityType>
<Association Name="Customer_Orders">
<End Type="WcfDataServicesForeignKey.Customer" Role="Customer_Orders_Source" Multiplicity="1">
<OnDelete Action="Cascade"/>
</End>
<End Type="WcfDataServicesForeignKey.Order" Role="Customer_Orders_Target" Multiplicity="*"/>
<ReferentialConstraint>
<Principal Role="Customer_Orders_Source">
<PropertyRef Name="Id"/>
</Principal>
<Dependent Role="Customer_Orders_Target">
<PropertyRef Name="CustomerId"/>
</Dependent>
</ReferentialConstraint>
</Association>
```

This is the behavior WCF Data Services implement, and it's required for third party OData client libraries like breeze.js to work against Web API OData properly.

Created Unassigned: AuthorizeAttribute can't be overriden [1095]

$
0
0
As the title says, it is currently not possible to override the AuthorizeAttribute set on Controllers with an AuthorizeAttribute set on Actions.
While this is in itself not a bug, it is quite an inconvenience. The attribute would be easier to use if you were able to set it on an Action as well as on the Controller. This would pretty much result in a similar usage process as with the AllowAnonymousAttribute, which can in fact override the Controller level AuthorizeAttribute.

Pseudo-code:
```
[Authorize(Roles = "Administrator")]
public class MyController : ApiController
{
//A hundred (exaggerating here) functions that are limited to Administrators thanks to the AuthorizeAttibute on the Controller.

[Authorize(Roles = "User,Administrator")] //FEATURE: Override only this single action to allow users as well. As it stands now, this is never reached due to the AuthorizeAttribute on the Controller.
public MyObject MyMoreAccesibleAction()
{
}

[AllowAnonymous] //AllowAnonymous can already override the AuthorizeAttribute
public MyObejct MyPublicMethod()
{
}
}
```

Commented Unassigned: AuthorizeAttribute can't be overriden [1095]

$
0
0
As the title says, it is currently not possible to override the AuthorizeAttribute set on Controllers with an AuthorizeAttribute set on Actions.
While this is in itself not a bug, it is quite an inconvenience. The attribute would be easier to use if you were able to set it on an Action as well as on the Controller. This would pretty much result in a similar usage process as with the AllowAnonymousAttribute, which can in fact override the Controller level AuthorizeAttribute.

Pseudo-code:
```
[Authorize(Roles = "Administrator")]
public class MyController : ApiController
{
//A hundred (exaggerating here) functions that are limited to Administrators thanks to the AuthorizeAttibute on the Controller.

[Authorize(Roles = "User,Administrator")] //FEATURE: Override only this single action to allow users as well. As it stands now, this is never reached due to the AuthorizeAttribute on the Controller.
public MyObject MyMoreAccesibleAction()
{
}

[AllowAnonymous] //AllowAnonymous can already override the AuthorizeAttribute
public MyObejct MyPublicMethod()
{
}
}
```
Comments: Ok I quickly wrote a custom Authorize attribute that can allow you to use the AuthorizeAttribute on Actions for those who are interested. ``` using System; using System.Linq; using System.Web.Http; using System.Web.Http.Controllers; [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)] public class OverridableAuthorizeAttribute : AuthorizeAttribute { public override void OnAuthorization(HttpActionContext actionContext) { if (actionContext.ActionDescriptor.GetCustomAttributes<AuthorizeAttribute>().Any()) { return; } base.OnAuthorization(actionContext); } } ```

Commented Feature: Add support for Status Code/HttpHeader attributes in web api help [1018]

$
0
0
This will allow a REST API to be self documenting for all inputs and outputs when applied on API functions.

Example usage:

__Http Headers__
[RequestHeaderDescription(Name = "X-Auth-Token", DescriptionResourceName = "XAuthHeaderDescription", DescriptionResourceType = typeof(ServiceApiResources))]


__Status Code__
[ResponseStatusDescription(StatusCode = HttpStatusCode.OK, DescriptionResourceName = "OnValidRequest", DescriptionResourceType = typeof(ServiceApiResources))]


Example Gists:
https://gist.github.com/anonymous/5478615
https://gist.github.com/anonymous/cd99f8808fed635d8ddb

How to use it within GenerateApiModel

https://gist.github.com/anonymous/5478617

Cheers,
Jamie
Comments: Thanks, you think you would be interested in adding it?

Edited Issue: AuthorizeAttribute can't be overriden [1095]

$
0
0
As the title says, it is currently not possible to override the AuthorizeAttribute set on Controllers with an AuthorizeAttribute set on Actions.
While this is in itself not a bug, it is quite an inconvenience. The attribute would be easier to use if you were able to set it on an Action as well as on the Controller. This would pretty much result in a similar usage process as with the AllowAnonymousAttribute, which can in fact override the Controller level AuthorizeAttribute.

Pseudo-code:
```
[Authorize(Roles = "Administrator")]
public class MyController : ApiController
{
//A hundred (exaggerating here) functions that are limited to Administrators thanks to the AuthorizeAttibute on the Controller.

[Authorize(Roles = "User,Administrator")] //FEATURE: Override only this single action to allow users as well. As it stands now, this is never reached due to the AuthorizeAttribute on the Controller.
public MyObject MyMoreAccesibleAction()
{
}

[AllowAnonymous] //AllowAnonymous can already override the AuthorizeAttribute
public MyObejct MyPublicMethod()
{
}
}
```

Edited Unassigned: Add foreign key information to the associations in the $metadata document [1094]

$
0
0
When there is an entity in a model that has an entity that explicitly exposes the foreign key of an association to another entity, make that information visible and available in the $metadata document.

For example:

```
<EntityType Name="Customer">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation" Name="Id" Type="Edm.Int32" Nullable="false" p6:StoreGeneratedPattern="Identity"/>
<Property Name="Name" Type="Edm.String" MaxLength="Max" FixedLength="false" Unicode="true"/>
<NavigationProperty Name="Orders" Relationship="WcfDataServicesForeignKey.Customer_Orders" ToRole="Customer_Orders_Target" FromRole="Customer_Orders_Source"/>
</EntityType>
<EntityType Name="Order">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation" Name="Id" Type="Edm.Int32" Nullable="false" p6:StoreGeneratedPattern="Identity"/>
<Property Name="CustomerId" Type="Edm.Int32" Nullable="false"/>
<Property Name="Purchased" Type="Edm.DateTime" Nullable="false"/>
<Property Name="Total" Type="Edm.Double" Nullable="false"/>
</EntityType>
<Association Name="Customer_Orders">
<End Type="WcfDataServicesForeignKey.Customer" Role="Customer_Orders_Source" Multiplicity="1">
<OnDelete Action="Cascade"/>
</End>
<End Type="WcfDataServicesForeignKey.Order" Role="Customer_Orders_Target" Multiplicity="*"/>
<ReferentialConstraint>
<Principal Role="Customer_Orders_Source">
<PropertyRef Name="Id"/>
</Principal>
<Dependent Role="Customer_Orders_Target">
<PropertyRef Name="CustomerId"/>
</Dependent>
</ReferentialConstraint>
</Association>
```

This is the behavior WCF Data Services implement, and it's required for third party OData client libraries like breeze.js to work against Web API OData properly.

Edited Unassigned: Make EntitySetConfiguration ctor public [1093]

$
0
0
The constructors in EntitySetConfiguration are public, while the constructors in EntitySetConfiguration<T> are internal. The constructors in EntitySetConfiguration were made public to ease unit testing, for consistency and for unit testing, please make EntitySetConfiguration<T> constructors also public.

Commented Unassigned: Allow to pass an empty ModelState into CreateErrorResponse [1091]

$
0
0
Would be nice if ```CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)``` didn't throw an exception in case ModelState is empty.
Comments: Hello, and thank you for submitting this issue. We are trying to understand under what circumstance the action should return an error response but with valid ModelState. Is the expectation that it should be an error, but without any error details? Or is the expectation that it should return a success status code?

Edited Issue: Allow to pass an empty ModelState into CreateErrorResponse [1091]

$
0
0
Would be nice if ```CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)``` didn't throw an exception in case ModelState is empty.

Edited Unassigned: Add foreign key information to the associations in the $metadata document [1094]

$
0
0
When there is an entity in a model that has an entity that explicitly exposes the foreign key of an association to another entity, make that information visible and available in the $metadata document.

For example:

```
<EntityType Name="Customer">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation" Name="Id" Type="Edm.Int32" Nullable="false" p6:StoreGeneratedPattern="Identity"/>
<Property Name="Name" Type="Edm.String" MaxLength="Max" FixedLength="false" Unicode="true"/>
<NavigationProperty Name="Orders" Relationship="WcfDataServicesForeignKey.Customer_Orders" ToRole="Customer_Orders_Target" FromRole="Customer_Orders_Source"/>
</EntityType>
<EntityType Name="Order">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation" Name="Id" Type="Edm.Int32" Nullable="false" p6:StoreGeneratedPattern="Identity"/>
<Property Name="CustomerId" Type="Edm.Int32" Nullable="false"/>
<Property Name="Purchased" Type="Edm.DateTime" Nullable="false"/>
<Property Name="Total" Type="Edm.Double" Nullable="false"/>
</EntityType>
<Association Name="Customer_Orders">
<End Type="WcfDataServicesForeignKey.Customer" Role="Customer_Orders_Source" Multiplicity="1">
<OnDelete Action="Cascade"/>
</End>
<End Type="WcfDataServicesForeignKey.Order" Role="Customer_Orders_Target" Multiplicity="*"/>
<ReferentialConstraint>
<Principal Role="Customer_Orders_Source">
<PropertyRef Name="Id"/>
</Principal>
<Dependent Role="Customer_Orders_Target">
<PropertyRef Name="CustomerId"/>
</Dependent>
</ReferentialConstraint>
</Association>
```

This is the behavior WCF Data Services implement, and it's required for third party OData client libraries like breeze.js to work against Web API OData properly.

Edited Unassigned: Make EntitySetConfiguration ctor public [1093]

$
0
0
The constructors in EntitySetConfiguration are public, while the constructors in EntitySetConfiguration<T> are internal. The constructors in EntitySetConfiguration were made public to ease unit testing, for consistency and for unit testing, please make EntitySetConfiguration<T> constructors also public.

Edited Unassigned: Exception inside PushStreamContent won't be caught by ExceptionFilterAttribute? [1089]

$
0
0
Hi,

I'm using PushStreamContent in asp.net web api to stream data to the client, I have derived from ExceptionFilterAttribute to capture all the exceptions and return standard HttpError to client. However,
I found that exception thrown inside PushStreamContent won't be caught by ExceptionFilterAttribute, it will return a "text/html" error message to client.
Below is the sample code:

response.Content = new PushStreamContent(
async (outputStream, httpContent, transportContext) =>
{
try
{
// do something and throw exception here

}
catch (Exception ex)
{
throw;
}
finally
{
outputStream.Close();
}
});

Edited Issue: Json.Encode doesn't encode array properties returned from Json.Decode [1085]

$
0
0
With this code:
```
var personJson = "{name:\"George\",aliases:[\"Peter\",\"David\"]}";
var person = Json.Decode(personJson);
person.name = "Michael";
personJson = Json.Encode(person);
```

Json.Encode is currently outputting:
```
"{\"name\":\"Michael\",\"aliases\":{}}"
```

When it should be:
```
"{\"name\":\"Michael\",\"aliases\":[\"Peter\",\"David\"]}"
```

The fix is in System.Web.Helpers/DynamicJavaScriptConverter.cs

```
// Get the value for each member in the dynamic object
foreach (string memberName in memberNames)
{
- values[memberName] = DynamicHelper.GetMemberValue(obj, memberName);
+ var value = DynamicHelper.GetMemberValue(obj, memberName);
+ if (value is DynamicJsonArray)
+ value = (object[])(DynamicJsonArray)value;
+ values[memberName] = value;
}

return values;
```

Edited Issue: Allow to pass an empty ModelState into CreateErrorResponse [1091]

$
0
0
Would be nice if ```CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)``` didn't throw an exception in case ModelState is empty.
Viewing all 7215 articles
Browse latest View live


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