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

Edited Issue: $expand with Entityframework fails on nested expands involving the original type [1028]

$
0
0
Model is as follows,

```
public class CustomersContext : DbContext
{
public DbSet<Customer> Customers { get; set; }

public DbSet<Order> Orders { get; set; }
}

public class Customer
{
public Customer()
{
Orders = new List<Order>();
}

public int ID { get; set; }

public string Name { get; set; }

public virtual ICollection<Order> Orders { get; set; }
}

public class Order
{
public int ID { get; set; }

public int Amount { get; set; }

public Customer Customer { get; set; }
}
```

Query - [http://localhost:8080/odata/Customers?$expand=Orders/Customer](http://localhost:8080/odata/Customers?$expand=Orders/Customer)

Exception:
The type 'System.Web.Http.OData.Query.Expressions.SelectExpandWrapper`1[[SOTests.Customer, SOTests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' appears in two structurally incompatible initializations within a single LINQ to Entities query. A type can be initialized in two places in the same query, but only if the same properties are set in both places and those properties are set in the same order.


Entityframework requires different types for projections involving an entity. For instance, EF fails to translate this query,
```
public class Test
{
public int Prop1 { get; set; }

public string Prop2 { get; set; }
}

var query = db.Customers.Select(c => new { Prop1 = new Test { Prop1 = c.ID }, Prop2 = new Test { Prop2 = c.Name } });
```

where as it can translate this query,

```
public class Test<T>
{
public int Prop1 { get; set; }

public string Prop2 { get; set; }
}

var query = db.Customers.Select(c => new { Prop1 = new Test<SomeUniqueType1> { Prop1 = c.ID }, Prop2 = new Test<SomeUniqueType2> { Prop2 = c.Name } });
```

Edited Issue: Document that IValueProvider.GetValue() returns null if the exact key is not found [1056]

$
0
0
Document that IValueProvider.GetValue() returns null if the exact key is not found.

This applies to both MVC and WebAPI versions.

Commented Issue: Document that IValueProvider.GetValue() returns null if the exact key is not found [1056]

$
0
0
Document that IValueProvider.GetValue() returns null if the exact key is not found.

This applies to both MVC and WebAPI versions.
Comments: Yishai, please update the XML docs.

Edited Issue: Twitter helper is broken [1088]

$
0
0
Microsoft-web-helpers has a Twitter helper in it. We were using the v1 Twitter API which was deprecated by Twitter recently - https://dev.twitter.com/blog/api-v1-is-retired

We’ll need to change the helper to call to the newer endpoints as described here - https://dev.twitter.com/docs/faq#17750

Edited Issue: WebApi model binding fails when Property inherits from Dictionary [1087]

$
0
0
When I submit the webpage data to the ApiController the binding will not bind the MyDictionary<string, string> ExtraData property. If I change the property to Dictionary<string, string> ExtraData property then Api controller will bind correctly. However this is not an option because the MyDictionary class has additional functionality that I need. I have four buttons on the webpage for submitting data to the apicontroller. The red button fails to load the MyDictionary ExtraData property. The 3 green buttons load MyDictionary and Dictionary property ok.

Commented Issue: WebApi model binding fails when Property inherits from Dictionary [1087]

$
0
0
When I submit the webpage data to the ApiController the binding will not bind the MyDictionary<string, string> ExtraData property. If I change the property to Dictionary<string, string> ExtraData property then Api controller will bind correctly. However this is not an option because the MyDictionary class has additional functionality that I need. I have four buttons on the webpage for submitting data to the apicontroller. The red button fails to load the MyDictionary ExtraData property. The 3 green buttons load MyDictionary and Dictionary property ok.
Comments: Yao, can you please take a look at this? Please email the triage team with your thoughts.

Closed Unassigned: Improve experience of using UriPathExtensionMapping with AttributeRouting [1086]

$
0
0
__Scenario__:
Its popular with users to use Uri path extensions to get content in a particular format even though one could use Accept headers. My understanding is that this is for users from browsers who cannot modify headers of the request that a browser sends.

I have the following ValuesController which uses AttributeRouting.

```
[RoutePrefix("api/values")]
public class ValuesController : ApiController
{
[HttpGet("")]
public IEnumerable<string> GetAll()
{
return new string[] { "value1", "value2" };
}

[HttpGet("{id}")]
public string GetSingle(int id)
{
return "value";
}

[HttpPost("")]
public void Post([FromBody]string value)
{
}

[HttpPut("{id}")]
public void Put(int id, [FromBody]string value)
{
}

[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
```

Now I would like to use UriPathExtensionMapping for the GetAll and GetSingle actions. I would like users to do "/api/values.xml" and "/api/values/10.xml" etc.

__Issue__:
I cannot do something like below for GetAll action, because we append the RoutePrefix with the action's RouteTemplate (ex: api/values/.{ext}). As you can notice this is not the desired behavior.

```
[HttpGet("")]
[HttpGet(".{ext}")]
public IEnumerable<string> GetAll()
```

__Workaround__:

__NOTE__: Here I would be placing the controller name on each of the individual action's route template, which ideally I would like to avoid.

```
[RoutePrefix("api")]
public class ValuesController : ApiController
{
[HttpGet("values")]
[HttpGet("values.{ext}")]
public IEnumerable<string> GetAll()
{
return new string[] { "value1", "value2" };
}

[HttpGet("values/{id}")]
[HttpGet("values/{id}.{ext}")]
public string GetSingle(int id)
{
return "value";
}

[HttpPost("values")]
public void Post([FromBody]string value)
{
}

[HttpPut("values/{id}")]
public void Put(int id, [FromBody]string value)
{
}

[HttpDelete("values/{id}")]
public void Delete(int id)
{
}
}
```

__Impact__:
1. User experience would be bad as users could be having many controllers and if they like to support Uri path extension on all of them, then they have to do the above workaround.
2. Alternatively, I can think of having non-attribute routes in WebApiConfig.cs which could probably fix this, what do you think?
Example:
```
config.Routes.MapHttpRoute(
name: "DefaultApiWithExtension2",
routeTemplate: "api/{controller}/{id}.{ext}"
);

config.Routes.MapHttpRoute(
name: "DefaultApiWithExtension1",
routeTemplate: "api/{controller}.{ext}");

config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
```

__Proposal__:
Could we introduce ability for individual actions' route attribute to ignore the RoutePrefix.

Example(__Notice__ the GetAll action's attribute):
```
[RoutePrefix("api/values")]
public class ValuesController : ApiController
{
[HttpGet("")]
[HttpGet("~/api/values.{ext}")] //NOTE
public IEnumerable<string> GetAll()
{
return new string[] { "value1", "value2" };
}

[HttpGet("{id}")]
[HttpGet("{id}.{ext}")]
public string GetSingle(int id)
{
return "value";
}

[HttpPost("")]
public void Post([FromBody]string value)
{
}

[HttpPut("{id}")]
public void Put(int id, [FromBody]string value)
{
}

[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
```
Comments: Does not seem like a very important scenario, and it has workarounds. If we hear about this more we will revisit.

Closed 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: This is by design, per Kiran's comments (kichalla).

Edited Feature: WebApi: Filters can't have a set execution order [1065]

$
0
0
MVC filter attributes support the Order property for setting the execution order when multiple instances are applied to a controller or method, those in Web API don't.

Commented Feature: Help Page: Expand documentation [1004]

$
0
0
The "Documentation" property in the ApiDescription and ApiParameterDescription should be expanded to include more XmlComment tags than just "<summary>".
Specifically, it should at least include the <example> tag (with valid sub tags such as <code>), the <exception> tag and the <list> tag.
That way we can actually do the documentation in code and use the HelpPage feature (which is a very good idea) for real world scenarios.

If you feel like it, please also implement these tags <example> and <exception> in the out of the box UI :-)


Morten Petteroe
Comments: Please take a look at this blog post on how to customize the help page to support other XML tags: http://blogs.msdn.com/b/yaohuang1/archive/2012/12/10/asp-net-web-api-help-page-part-3-advanced-help-page-customizations.aspx

Created 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.

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: ``` { "message":"Anerrorhasoccurred.", "exceptionMessage":"Themodelstateisvalid. Parametername:modelState", "exceptionType":"System.ArgumentException", "stackTrace":"atSystem.Web.Http.HttpError..ctor(ModelStateDictionarymodelState,BooleanincludeErrorDetail) atSystem.Net.Http.HttpRequestMessageExtensions.<>c__DisplayClassb.<CreateErrorResponse>b__a(BooleanincludeErrorDetail) atSystem.Net.Http.HttpRequestMessageExtensions.CreateErrorResponse(HttpRequestMessagerequest,HttpStatusCodestatusCode,Func`2errorCreator) atSystem.Net.Http.HttpRequestMessageExtensions.CreateErrorResponse(HttpRequestMessagerequest,HttpStatusCodestatusCode,ModelStateDictionarymodelState) atApp.Web.Controllers.RegisterController.Post(NewUseruser)inc:\Projects\SiteSDK\Source\Web\Controllers\RegisterController.cs:line46 atlambda_method(Closure,Object,Object[]) atSystem.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Objectinstance,Object[]methodParameters) atSystem.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Objectinstance,Object[]arguments) atSystem.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4() atSystem.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1func,CancellationTokencancellationToken)" } ```

Created Unassigned: Deprecate Microsoft.Web.Helpers [1092]

$
0
0
The Microsoft.Web.Helpers project contains helper code to interact with Bing, Facebook, Twitter, etc.
But recently these helpers have become broken due to API changes for their respective services.

Rather than fix and maintain these helpers, the entire project should be deprecated.

This also means the NuGet packages microsoft-web-helpers and Microsoft.AspNet.Web.Helpers.Mvc will be deprecated, because both contain the binary from Microsoft.Web.Helpers

Closed Unassigned: Deprecate Microsoft.Web.Helpers [1092]

$
0
0
The Microsoft.Web.Helpers project contains helper code to interact with Bing, Facebook, Twitter, etc.
But recently these helpers have become broken due to API changes for their respective services.

Rather than fix and maintain these helpers, the entire project should be deprecated.

This also means the NuGet packages microsoft-web-helpers and Microsoft.AspNet.Web.Helpers.Mvc will be deprecated, because both contain the binary from Microsoft.Web.Helpers

Commented Unassigned: Deprecate Microsoft.Web.Helpers [1092]

$
0
0
The Microsoft.Web.Helpers project contains helper code to interact with Bing, Facebook, Twitter, etc.
But recently these helpers have become broken due to API changes for their respective services.

Rather than fix and maintain these helpers, the entire project should be deprecated.

This also means the NuGet packages microsoft-web-helpers and Microsoft.AspNet.Web.Helpers.Mvc will be deprecated, because both contain the binary from Microsoft.Web.Helpers
Comments: Why do u wanna deprecate the one of the popular libraries on NuGet where it's very possible that you can maintain it? very bad idea. good call on closing the issue.

Closed Issue: $select and $expand not working properly for complex types in json formatter [1048]

$
0
0
Given the following model:

```
public class JsonSelectCustomer
{
public int Id { get; set; }
public string Name { get; set; }
public virtual IList<JsonSelectOrder> JsonSelectOrders { get; set; }
}

public class JsonSelectPremiumCustomer : JsonSelectCustomer
{
public string Category { get; set; }
public IList<JsonSelectBonus> Bonuses { get; set; }
}

public class JsonSelectBonus
{
public int Id { get; set; }
public double Ammount { get; set; }
}

public class JsonSelectOrder
{
public int Id { get; set; }
public DateTime Date { get; set; }
public JsonSelectAddress BillingAddress { get; set; }
public virtual IList<JsonSelectOrderDetail> OrderDetails { get; set; }
}

public class JsonSelectAddress
{
public string FirstLine { get; set; }
public string SecondLine { get; set; }
public int ZipCode { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Country { get; set; }
}

public class JsonSelectOrderDetail
{
public int Id { get; set; }
public string Name { get; set; }
public int Ammount { get; set; }
public double Price { get; set; }
}
```

When a customer issues the following query:
/api/JsonSelectCustomer?$select=Id,JsonSelectOrders&$expand=JsonSelectOrders

The JsonSelectAddress property doesn't get serialized as it does in the OData case.
Here is the response payload sample:

```
[
{
"Id": 0,
"JsonSelectOrders": []
},
{
"Id": 1,
"JsonSelectOrders": [
{
"Id": 0,
"Date": "2013-05-14T11:20:45.2454402-07:00"
}
]
},
{
"Id": 2,
"JsonSelectOrders": [
{
"Id": 0,
"Date": "2013-05-14T11:20:45.2464399-07:00"
},
{
"Id": 1,
"Date": "2013-05-13T11:20:45.2464399-07:00"
}
]
},
{
"Id": 3,
"JsonSelectOrders": [
{
"Id": 0,
"Date": "2013-05-14T11:20:45.2474403-07:00"
},
{
"Id": 1,
"Date": "2013-05-13T11:20:45.2474403-07:00"
},
{
"Id": 2,
"Date": "2013-05-12T11:20:45.2474403-07:00"
}
]
},
{
"Id": 4,
"JsonSelectOrders": [
{
"Id": 0,
"Date": "2013-05-14T11:20:45.2474403-07:00"
},
{
"Id": 1,
"Date": "2013-05-13T11:20:45.2474403-07:00"
},
{
"Id": 2,
"Date": "2013-05-12T11:20:45.2474403-07:00"
},
{
"Id": 3,
"Date": "2013-05-11T11:20:45.2474403-07:00"
}
]
},
{
"Id": 5,
"JsonSelectOrders": [
{
"Id": 0,
"Date": "2013-05-14T11:20:45.2474403-07:00"
},
{
"Id": 1,
"Date": "2013-05-13T11:20:45.2474403-07:00"
},
{
"Id": 2,
"Date": "2013-05-12T11:20:45.2474403-07:00"
},
{
"Id": 3,
"Date": "2013-05-11T11:20:45.2474403-07:00"
},
{
"Id": 4,
"Date": "2013-05-10T11:20:45.2474403-07:00"
}
]
},
{
"Id": 6,
"JsonSelectOrders": [
{
"Id": 0,
"Date": "2013-05-14T11:20:45.2474403-07:00"
},
{
"Id": 1,
"Date": "2013-05-13T11:20:45.2474403-07:00"
},
{
"Id": 2,
"Date": "2013-05-12T11:20:45.2474403-07:00"
},
{
"Id": 3,
"Date": "2013-05-11T11:20:45.2474403-07:00"
},
{
"Id": 4,
"Date": "2013-05-10T11:20:45.2474403-07:00"
},
{
"Id": 5,
"Date": "2013-05-09T11:20:45.2474403-07:00"
}
]
},
{
"Id": 7,
"JsonSelectOrders": [
{
"Id": 0,
"Date": "2013-05-14T11:20:45.2474403-07:00"
},
{
"Id": 1,
"Date": "2013-05-13T11:20:45.2474403-07:00"
},
{
"Id": 2,
"Date": "2013-05-12T11:20:45.2474403-07:00"
},
{
"Id": 3,
"Date": "2013-05-11T11:20:45.2474403-07:00"
},
{
"Id": 4,
"Date": "2013-05-10T11:20:45.2474403-07:00"
},
{
"Id": 5,
"Date": "2013-05-09T11:20:45.2474403-07:00"
},
{
"Id": 6,
"Date": "2013-05-08T11:20:45.2474403-07:00"
}
]
},
{
"Id": 8,
"JsonSelectOrders": [
{
"Id": 0,
"Date": "2013-05-14T11:20:45.2474403-07:00"
},
{
"Id": 1,
"Date": "2013-05-13T11:20:45.2474403-07:00"
},
{
"Id": 2,
"Date": "2013-05-12T11:20:45.2474403-07:00"
},
{
"Id": 3,
"Date": "2013-05-11T11:20:45.2474403-07:00"
},
{
"Id": 4,
"Date": "2013-05-10T11:20:45.2474403-07:00"
},
{
"Id": 5,
"Date": "2013-05-09T11:20:45.2474403-07:00"
},
{
"Id": 6,
"Date": "2013-05-08T11:20:45.2474403-07:00"
},
{
"Id": 7,
"Date": "2013-05-07T11:20:45.2474403-07:00"
}
]
},
{
"Id": 9,
"JsonSelectOrders": [
{
"Id": 0,
"Date": "2013-05-14T11:20:45.2474403-07:00"
},
{
"Id": 1,
"Date": "2013-05-13T11:20:45.2474403-07:00"
},
{
"Id": 2,
"Date": "2013-05-12T11:20:45.2474403-07:00"
},
{
"Id": 3,
"Date": "2013-05-11T11:20:45.2474403-07:00"
},
{
"Id": 4,
"Date": "2013-05-10T11:20:45.2474403-07:00"
},
{
"Id": 5,
"Date": "2013-05-09T11:20:45.2474403-07:00"
},
{
"Id": 6,
"Date": "2013-05-08T11:20:45.2474403-07:00"
},
{
"Id": 7,
"Date": "2013-05-07T11:20:45.2474403-07:00"
},
{
"Id": 8,
"Date": "2013-05-06T11:20:45.2474403-07:00"
}
]
}
]
```


Closed Issue: The "Model" property will cause model is null [924]

$
0
0
I have Model Class "Project", it has a "Model" property, type is String.
When I create a Action as below:
[HttpPost]
public ActionResult Create(Project model)
{
if (ModelState.IsValid)
{
// save model into database
}
return View(model);
}
Run this action , I found the parameter "model" in Create method is always null, and with exception is "Can't convert String into Project".
Then , I change this property from "Model" to "ModelNumber", everything is OK!
Comments: Thanks for reporting this issue. This is an unfortunate side effect of model binding. Your workaround is right, but since the scenario is not very common we chose to keep it as is.

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: Hey Dave, Our guidelines are allowing to take your contribution through a pull request. We would appreciate if you could turn your file attachment into a pull request. In order for us to process the pull request we have some information on the wiki page on Contributions describing the Contributor License Agreement (CLA) that needs to be sent in. Once we get that verified we can start processing your code changes. The full info is here: https://aspnetwebstack.codeplex.com/wikipage?title=Contributing We're looking forward to the change! Thanks, Yishai

Created 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: [WebApiOnOwin]Provide IAppBuilder extension which accepts HttpServer [1025]

$
0
0
Scenario: Use Web API request batching on Owin.

Our DefaultHttpBatchHandler requires us to supply the HttpServer instance to it, so I cannot use the 'UseWebApi' extension here. So, I am using the 'UseMessageHandler' extension:

```
public void Configuration(IAppBuilder appBuilder)
{
HttpConfiguration config = new HttpConfiguration();
config.Services.Replace(typeof(IHostBufferPolicySelector), new CustomBufferPolicySelector());

HttpServer server = new HttpServer(config);

config.MapHttpAttributeRoutes();
config.Routes.MapHttpBatchRoute("batchRoute", "api/$batch", new DefaultHttpBatchHandler(httpServer: server));

appBuilder.UseHttpMessageHandler(messageHandler: server);
}
```

Also the 'UseHttpMessageHandler' (below) uses the default buffer policy selector and does not take the buffer policy from the configuration of HttpServer

```
/// <summary>
/// Adds a component to the OWIN pipeline for running an <see cref="HttpMessageHandler"/>.
/// </summary>
/// <param name="builder">The application builder.</param>
/// <param name="messageHandler">The message handler.</param>
/// <returns>The application builder.</returns>
public static IAppBuilder UseHttpMessageHandler(this IAppBuilder builder, HttpMessageHandler messageHandler)
{
return builder.Use(typeof(HttpMessageHandlerAdapter), messageHandler, _defaultBufferPolicySelector);
}
```

We need a convenient extension for users to be able to supply the HttpServer instance.
Comments: Since batching is now a first class feature in Web API, I think we need to provide a more easily discoverable way of using it. Currently user has to figure out how he could achieve it with Katana. Also, if you notice in the second part of the bug, the appropriate buffer policy isn't being picked up too.
Viewing all 7215 articles
Browse latest View live


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