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

Edited Issue: Exceptions in DefaultODataPathHandler result in 500 [909]

$
0
0
ODataExceptions in DefaultODataPathHandler mean that the incoming request is incorrect or not supported. These should result in 404 or 400 rather than a 500.

For now, a workaround would be to have a custom path handler that looks like this,
```
public class CustomPathHandler : DefaultODataPathHandler
{
public override ODataPath Parse(IEdmModel model, string odataPath)
{
try
{
return base.Parse(model, odataPath);
}
catch (ODataException e)
{
return null;
}
}
}
```

Commented Issue: Direct link generation should be consistent with Url.Link when the OData path is empty and there is a route prefix [793]

$
0
0
The direct link generation generates "http://localhost/prefix/", while Url.Link generates "http://localhost/prefix" when the OData path is empty. There's a slight inconsistency here that we should fix.
Comments: If it's super easy fix it.

Edited Feature: Add json.net support for Delta [777]

$
0
0
Currently Delta<T> only works with the ODataFormatter. It should also work with json serialized from JSON.NET/JavaScript/JsonMediaTypeFormatter. Json is used heavily by web api and various languages (C#, JavaScript) and almost every new Microsoft product (E.G., Azure...)

Here is a discussion with raghuramn on an issue I ran into with using Delta<T> with json (http://aspnetwebstack.codeplex.com/discussions/429798#post988342).

Closed Issue: Considering support ModelState error in ODataError [565]

$
0
0
Discussed with Youssef that ODataError right now doesn't support custom error, so we will lose the modelstate's errors in odata error message.

However, ModelState errors are very common in real application to help caller to identify what's wrong with his parameter. We'd better to support it, otherwise user has to parse the modelstate by themselves to convert to ODataError.
Comments: Seems like we have a reasonable workaround, we haven't heard to the contrary in almost two months. If you disagree feel free to reopen and provide the reason why the workaround doesn't work for you.

Edited Feature: [Routing] Support namespace-based controller disambiguation in Web API [516]

Edited Feature: [Routing] Support namespace-based controller disambiguation in Web API [516]

Closed Issue: [AttributeRouting]Parsing error when using paranthesis in the route template's default values [978]

$
0
0
For the following action:

Note: the default value is a guid enclosed { , } characters.
```
[HttpGet("ForGuids/v3/{id:guid={6A9B7F3B-ED68-4759-ABBA-959ED47EB326}}")]
public string ForGuids(Guid id)
{
return "ForGuids:" + id.ToString();
}
```

Following error is thrown during configuration:

_System.ArgumentException : There is an incomplete parameter in this path segment: '{id}}'. Check that each '{' character has a matching '}' character.
Parameter name: routeTemplate

at System.Web.Http.Routing.HttpRouteParser.Parse(String routeTemplate) in c:\WebstackRuntime\Runtime\src\System.Web.Http\Routing\HttpRouteParser.cs:line 102
at System.Web.Http.Routing.HttpRoute..ctor(String routeTemplate, HttpRouteValueDictionary defaults, HttpRouteValueDictionary constraints, HttpRouteValueDictionary dataTokens, HttpMessageHandler handler) in c:\WebstackRuntime\Runtime\src\System.Web.Http\Routing\HttpRoute.cs:line 68
at System.Web.Http.Routing.HttpRoute..ctor(String routeTemplate, HttpRouteValueDictionary defaults, HttpRouteValueDictionary constraints) in c:\WebstackRuntime\Runtime\src\System.Web.Http\Routing\HttpRoute.cs:line 49
at System.Web.Http.Routing.HttpRouteBuilder.BuildHttpRoute(HttpRouteValueDictionary defaults, HttpRouteValueDictionary constraints, String routeTemplate) in c:\WebstackRuntime\Runtime\src\System.Web.Http\Routing\HttpRouteBuilder.cs:line 111
at System.Web.Http.Routing.HttpRouteBuilder.BuildHttpRoute(String routeTemplate, IEnumerable`1 httpMethods, String controllerName, String actionName) in c:\WebstackRuntime\Runtime\src\System.Web.Http\Routing\HttpRouteBuilder.cs:line 99
at System.Web.Http.HttpConfigurationExtensions.CreateAttributeRoutes(HttpRouteBuilder routeBuilder, String controllerName, Collection`1 routePrefixes, IGrouping`2 actionGrouping) in c:\WebstackRuntime\Runtime\src\System.Web.Http\HttpConfigurationExtensions.cs:line 143
at System.Web.Http.HttpConfigurationExtensions.MapHttpAttributeRoutes(HttpConfiguration configuration, HttpRouteBuilder routeBuilder) in c:\WebstackRuntime\Runtime\src\System.Web.Http\HttpConfigurationExtensions.cs:line 90
at System.Web.Http.HttpConfigurationExtensions.MapHttpAttributeRoutes(HttpConfiguration configuration) in c:\WebstackRuntime\Runtime\src\System.Web.Http\HttpConfigurationExtensions.cs:line 59
at WebStack.QA.Tests.AttributeRouting.DefaultValuesTest.UpdateConfiguration(HttpConfiguration config) in c:\WebstackRuntime\QA\Func\src\MainTests\Tests\AttributeRouting\DefaultValuesTest.cs:line 35_
Comments: GUIDs are already supported in attribute routing and you can just leave out the curly braces from the GUID. We can certainly improve the parser, but it won't really change this scenario.

Edited Feature: Support IServiceProvider Injection for DataAnnotations validations through DependencyResolver [463]

$
0
0
I am not completely sure but at first glance, it seems to me that IServiceProvider for DataAnnotations validations is completely ignored in ASP.NET Web API.

Here is a quote from
Jeff Handley's blog post (http://jeffhandley.com/archive/2010/10/25/RiaServicesValidationContext.aspx):

"Consider the scenario where a validator needs to access the database; you certainly wouldn’t couple a validation method to your data access layer, would you? Instead, you would make your repository available as a service that your validation method can consume in a loosely-coupled manner. In order to easily support these scenarios, ValidationContext implements IServiceProvider. This interface requires a single method, GetService(Type). Using GetService, a validation method can access your repository without knowing how to instantiate or initialize it."

Here is the Validate method of the DataAnnotationsModelValidator class:

public override IEnumerable<ModelValidationResult> Validate(ModelMetadata metadata, object container)
{
// Per the WCF RIA Services team, instance can never be null (if you have
// no parent, you pass yourself for the "instance" parameter).
ValidationContext context = new ValidationContext(container ?? metadata.Model, null, null);
context.DisplayName = metadata.GetDisplayName();

ValidationResult result = Attribute.GetValidationResult(metadata.Model, context);

if (result != ValidationResult.Success)
{
return new ModelValidationResult[] { new ModelValidationResult { Message = result.ErrorMessage } };
}

return new ModelValidationResult[0];
}

It would be great to inspect the global DependencyResolver and see whether there is any IServiceProvider type registered. If so, you can pass that into ValidationContext instead of passing null.

I am completely unsure if this is possible to implement because at the first glance, it seems that the validation part doesn't have any knowledge of the HttpConfiguration.

Edit:

Also, this would be much more useful for the IValidatableObject validation. A sample use case scenario here is to check an existence of a value inside the database.

Commented Feature: Support IServiceProvider Injection for DataAnnotations validations through DependencyResolver [463]

$
0
0
I am not completely sure but at first glance, it seems to me that IServiceProvider for DataAnnotations validations is completely ignored in ASP.NET Web API.

Here is a quote from
Jeff Handley's blog post (http://jeffhandley.com/archive/2010/10/25/RiaServicesValidationContext.aspx):

"Consider the scenario where a validator needs to access the database; you certainly wouldn’t couple a validation method to your data access layer, would you? Instead, you would make your repository available as a service that your validation method can consume in a loosely-coupled manner. In order to easily support these scenarios, ValidationContext implements IServiceProvider. This interface requires a single method, GetService(Type). Using GetService, a validation method can access your repository without knowing how to instantiate or initialize it."

Here is the Validate method of the DataAnnotationsModelValidator class:

public override IEnumerable<ModelValidationResult> Validate(ModelMetadata metadata, object container)
{
// Per the WCF RIA Services team, instance can never be null (if you have
// no parent, you pass yourself for the "instance" parameter).
ValidationContext context = new ValidationContext(container ?? metadata.Model, null, null);
context.DisplayName = metadata.GetDisplayName();

ValidationResult result = Attribute.GetValidationResult(metadata.Model, context);

if (result != ValidationResult.Success)
{
return new ModelValidationResult[] { new ModelValidationResult { Message = result.ErrorMessage } };
}

return new ModelValidationResult[0];
}

It would be great to inspect the global DependencyResolver and see whether there is any IServiceProvider type registered. If so, you can pass that into ValidationContext instead of passing null.

I am completely unsure if this is possible to implement because at the first glance, it seems that the validation part doesn't have any knowledge of the HttpConfiguration.

Edit:

Also, this would be much more useful for the IValidatableObject validation. A sample use case scenario here is to check an existence of a value inside the database.
Comments: Unfortunately looks like we won't be able to fit this very legitimate scenario in Version 5.0. Moving the vNext

Closed Issue: [Routing] Complex Type Action Method Parameters and Action Selection [380]

$
0
0
With the default action selector (ApiControllerActionSelector), we cannot have multiple methods which accept complex type params along with FromUri applied. For exmaple, Cmd1 and Cmd2 are two different types and have different properties. If we have Get(Cmd1 cmd) and Get(Cmd2 cmd) + the route template of "api/{controller}", we would get the ambiguity error by the ApiControllerActionSelector.

Here,you can see a repo: https://gist.github.com/3557926

To work around this problem, I wanted to customize the ApiControllerActionSelector but it's not that much customizable. I didn't wanna go and write my own stuff because ApiControllerActionSelector has some really nice featues such as caching and selection logic. So, Just to try things out, I cloned the source of ApiControllerActionSelector and created a shadow copy. Then, I go inside it and implement my own stuff there:

https://github.com/WebAPIDoodle/WebAPIDoodle/commit/f3d015dd595a6203b563c4b3c15ef308a5f86362

The customization was minor but useful IMO:

https://github.com/WebAPIDoodle/WebAPIDoodle/commit/f3d015dd595a6203b563c4b3c15ef308a5f86362#L11R131

With this action selector, we can have the ability specify action parameter through an Attribute named as UriParameteSAttribute. We just need to replace the default action selector with this one and apply the UriParametersAttribute to the action method, the specify the parameter on the attribute. Sample:

https://gist.github.com/3559725

I am not suggesting that this should be baked into the framework as it is but a solution to this problem would make it really nice.
Comments: We prefer not to add more attributes in this case.

Edited Issue: '/', '\' and ' ' is not handled correctly in string primary key in edit link [498]

$
0
0
'/', '\' can't route to the correct action
' ' will be null value when binding to the id parameter.

Repro code:
public static void RegisterODataRoutes(this HttpConfiguration configuration)
{
// Metadata routes to support $metadata and code generation in the WCF Data Service client.
configuration.Routes.MapHttpRoute(ODataRouteNames.Metadata, "$metadata", new { Controller = "ODataMetadata", Action = "GetMetadata" });
configuration.Routes.MapHttpRoute(ODataRouteNames.ServiceDocument, string.Empty, new { Controller = "ODataMetadata", Action = "GetServiceDocument" });

// Relationship routes (notice the parameters is {type}Id not id, this avoids colliding with GetById(id)).
configuration.Routes.MapHttpRoute(ODataRouteNames.PropertyNavigation, "{controller}({parentId})/{navigationProperty}");

// Route for manipulating links.
//configuration.Routes.MapHttpRoute(ODataRouteNames.Link, "{controller}({id})/$links/Products");
configuration.Routes.MapHttpRoute(ODataRouteNames.Link, "{controller}({id})/$links/{navigationProperty}");

// Routes for urls both producing and handling urls like ~/Product(1), ~/Products() and ~/Products
configuration.Routes.MapHttpRoute("GetByStringId", "{controller}('{id}')");
configuration.Routes.MapHttpRoute(ODataRouteNames.GetById, "{controller}({id})");
configuration.Routes.MapHttpRoute(ODataRouteNames.DefaultWithParentheses, "{controller}()");
configuration.Routes.MapHttpRoute(ODataRouteNames.Default, "{controller}");
}

[EntitySetAttribute("todo")]
[DataServiceKeyAttribute("Name")]
public class Todo
{
[Key]
public string Name { get; set; }
}

public class TodoController : ApiController
{
static TodoController()
{
var todoes = new List<Todo>();
foreach (var c in "/ \\")
{
todoes.Add(new Todo()
{
Name = c.ToString()
});
}
Todoes = todoes;
}

public static IEnumerable<Todo> Todoes { get; set; }

public IEnumerable<Todo> Get()
{
return Todoes;
}

public Todo GetById(string id)
{
return Todoes.FirstOrDefault(t => t.Name == id);
}

[AcceptVerbs("Merge")]
public Todo Put(string id, Todo todo)
{
todo = Todoes.FirstOrDefault(t => t.Name == id);
return todo;
}
}

Client code:
[Fact]
public void TestSpecialCharacters()
{
DataServiceContext ctx = new DataServiceContext(new Uri(this.BaseAddress));
var todoes = ctx.CreateQuery<Todo>("todo").ToList();

foreach (var todo in todoes)
{
Uri selfLink;
Assert.True(ctx.TryGetUri(todo, out selfLink));
Console.WriteLine(selfLink);

ctx.UpdateObject(todo);

var response = ctx.SaveChanges().Single();

Assert.Equal(200, response.StatusCode);
}
}

Commented Unassigned: [Regression]XmlMediaTypeFormatter does not serialize Uri input correctly [1070]

$
0
0
Uri- file://[7f:d:ee9e::7a:828e:c]/-861%A3+/F3&m/@pM is serialized as file://[7f:d:ee9e::7a:828e:c]/-861%**25**A3+/F3&m/@pM on server by XmlMediaTypeFormatter(Notice 25(bolded) added to the url). This works fine when using Json formatter.

Here is my client code
HttpClient client = new HttpClient();
Uri myUri = new Uri("//[07f:d:EE9e::7a:828E:C]/-861%A3+/F3&m/@pM", UriKind.Absolute);

HttpRequestMessage request = new HttpRequestMessage()
{
Content = new ObjectContent<Uri>(myUri, new XmlMediaTypeFormatter()),
RequestUri = new Uri(baseAddress + "/My/EchoUriFromBody"),
Method = new HttpMethod("Post"),
};
var response = client.SendAsync(request).Result;
var myResult = response.Content.ReadAsAsync<Uri>(new List<MediaTypeFormatter>(){new XmlMediaTypeFormatter()}).Result;

Controller code
public class MyController : ApiController
{
[AcceptVerbs("PUT", "POST", "DELETE")]
public Task<Uri> EchoUriFromBody([FromBody]Uri input)
{
var task = Task.Factory.StartNew(() => input);
return task;
}
}
Comments: You marked the bug as regression, in what version did this work in the XML formatter?

Created Unassigned: Group views by Department [1076]

$
0
0
I just submitted a [discussion](https://aspnetwebstack.codeplex.com/discussions/445529) about grouping models that are generated by a data first design to be group by a department name. It may even be better to group by a schema name b/c you can have shemas in a database for separating out tables. That way if you grouped stuff by a department or by a schema in both your controllers and views it would make organizing these data driven items much easier.

Also this would help with separation of concerns and I know if I delete stuff from these directories that I didn't delete something important as I continue a data driven design.


Edited Unassigned: WebGrid: Allow customizing header rendering [1069]

$
0
0
Add opportunity to customize header output. Like it made with "Format" property. Or just change Header type to object. To have a way for manage output.

```
namespace System.Web.Helpers {
public class WebGridColumn {

public bool CanSort { get; set; }

public string ColumnName { get; set; }

public Func<dynamic, object> Format { get; set; }

public __object__ Header { get; set; }

public string Style { get; set; }

}

}
```

Created Unassigned: Add support for Silverlight 5 to System.Net.Http.Formatting [1077]

$
0
0
While System.Net.Http currently supports Silverlight 5, the above library currently doesn't. Instead the portable version of the library only supports .Net45, Windows Store, and WP8 apps.

Edited Issue: After enabling tracing, IControllerConfiguration.Initialize will execute multiple times [755]

$
0
0
Attached repro code.

Steps to repro:
1. Create a custom controller configuration attribute
2. Put the attribute on web api controller
3. Create a self or web host application for web api
4. Enable tracing on the service
5. Run the service
6. Send a client request to reach the controller's action to make it initializing

Possible fix to this bug:
1. Creating an protected copy only constructor in HttpControllerDescriptor which doesn't do any initialization
2. Change HttpControllerDescriptorTracer's constructor to use copy only constructor

Edited Issue: BrowserHelpers.GetOverriddenBrowser should use StringComparison.OrdinalIgnoreCase [702]

$
0
0
if (!String.Equals(overriddenUserAgent, httpContext.Request.UserAgent))
{
overriddenBrowser = createBrowser(overriddenUserAgent);
}

Edited Issue: Html.EditorFor helper generates wrong date/time format [630]

$
0
0
In MVC applications, if someone uses the Html.EditorFor helper to generate UI for a model that includes a DateTime field, the resulting HTML markup will render a date in a culture format that doesn't resemble the one prescribed by the HTML 5 standard, which references RFC 3339.

To fix this, we need to change our generated markup to use one of the formats prescribed in the RFC.

Edited Issue: Validators in WebPages Do Not Work When Using @RenderPage [446]

$
0
0
In the Web Pages framework, if I browse directly to a page that contains a form, validation works as intended. If I call the page from another page using RenderPage, the ValidationSummary and ValidationMessage controls do not display their messages:
@RenderPage("~_MyForm.cshtml")

See attached sample for example.

Edited Issue: GetBingHtml method in Maps helper emits literal tags in JavaScript; fails to load map [363]

$
0
0
To reproduce this issue, follow these steps:

1. In a Razor web site, install the latest ASP.NET Web Helpers Library version using NuGet.
2. On a CSHTML page that references JQuery, add the following. (Replace the API key below with your own.)

@Maps.GetBingHtml("Av2RVhcYgg4FaKlj1uvfJIwfLtTkKXjcxhDEIptrMWKGV55chQSrjmEmrhh2dF1K", "Seattle")

3. Request the page in the browser of your choice.

Result: The map fails to load. Examining the page source reveals that literal <text> tags are emitted in the helper's inline JavaScript.
Expected: We should be emitting valid JavaScript.
Viewing all 7215 articles
Browse latest View live


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