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

Edited Issue: JQuery Validation plugin - include additional-methods file [1057]

$
0
0
The JQuery Validation plugin is normally bundled with a file named additional-methods.js that adds some more validation methods to the basic ones that are in the plugin.

Two of which, 'accept' (for validating mime-types on input[type=file]) and 'extension' for validating file extensions (again, on input[type=file]), have support within MVC in the form of validation attributes (FileExtensionsAttribute and AcceptAttribute)

Currently the templates provided does not include that additional file, hence out-of-the-box these validation attributes only apply on server-side.

A fix would be to either add the nuget-package for the additional methods into the template, or to update the JQuery.validation nuget package to always include the additional methods file.
The default Bundle for jquaeyval should be updated as well.


Edited Unassigned: Make ODataQueryOptions behave more like a property [1061]

$
0
0
As of right now, every time the user calls EntitySetController.QueryOptions we create a new instance of ODataQueryOptions<T>.

This causes some problems when the user calls it several times and makes changes on one of the instances as the customer expects the same instance to be returned every time he calls EntitySetController.QueryOptions.

Edited Unassigned: [HelpPage]Do not display parameter info when action parameter is HttpRequestMessage [1060]

$
0
0
For the following action, we are currently displaying parameter info(attached an snapshot image) in help page:
```
public IEnumerable<string> Get(HttpRequestMessage request)
{
return new string[] { "value1", "value2" };
}
```

We should avoid displaying this information as from end user's perspective, it doesn't make sense.

We already do not show parameter info for parameter CancellationToken. We could add one more check for HttpRequestMessage too.

In "\Areas\HelpPage\Views\Help\DisplayTemplates\Parameters.cshtml":
```
// Don't show CancellationToken because it's a special parameter
if (!typeof(CancellationToken).IsAssignableFrom(parameter.ParameterDescriptor.ParameterType))
{
```

Commented Unassigned: Global error handler for Web API [1001]

$
0
0
If my Web API application is going to return an error to a client, I want to know about it.

I want to set up something like ELMAH to notify me when the problem occurs, and I want full details of the error, including exception stack trace, logged on the server.

In MVC, the __Application_Error__ event is how you achive this, but in Web Api this event often isn't triggered because exceptions are converted into **HttpResponseMessage**s higher in the call stack, and because some error conditions create a **HttpResponseMessage** directly without using an exception. One source of this is __HttpControllerDispatcher.SendAsync__, which catches all exceptions and turns them into error responses, discarding the exception information.

Here are some examples of exceptions that I am interested in handling:

* Exceptions thrown from action methods and action filters
* Exceptions thrown when creating a controller instance
* Exceptions due to routing errors, bad requests, authentication problems, and invalid OData queries
* Exceptions thrown when an IQueryable returned by an action method fails to execute
* Exceptions thrown by custom message handlers and formatters

When I started using Web API, I was surprised when my __Application_Error__ handler did not pick up an action method exception. I added a global __ExceptionFilterAttribute__ to take care of that, but then found several other categories of errors that could be returned to the client and still leave silence in the server logs.

In a production environment, relying on clients to report errors and having no error information available on the server will make diagnosing problems reactive and difficult.

Please provide a global error handling event for Web API, so that error details can be logged and notifications sent. The event should provide access to unhandled exceptions and non-success **HttpResponseException**s and **HttpResponseMessage**s. In the case of **HttpError** objects created from an exception, the exception details should be retained for the error handling event.
Comments: I would like to be able to have both IIS custom errors for normal http exceptions AND json formatted exceptions when they emanate from the Web API. At the moment, I have to always return HTTP 200 from the Web API so that the JSON formatted response does not get hijacked by IIS (e.g., returning a 500 http status code will mean IIS will override my JSON output with a custom html message, which is what I want for all other scenarios other than WEB API interactions). Also, the problem is, sometimes there's a deserialization exception that occurs further up the stack from my actual Web API code (usually the deferred invocation of a LINQ query)... I cannot intercept this exception and return a HTTP 200 manually to avoid the IIS override issue, so in this case Web API will return a 500 which subsequently gets overridden by IIS. I have tried using a DelegatingHandler to intercept the Web API request/response cycle so that I could at least log the error, even when IIS overrides the JSON response; but it seems even at that level, no exception has occurred from the deferred LINQ query. If I'm wrong, please could you demonstrate how to work-around this. A lot of people seem to be talking about this, but with no real solutions forthcoming. Many thanks for your help Kris

Commented Unassigned: Make ODataQueryOptions behave more like a property [1061]

$
0
0
As of right now, every time the user calls EntitySetController.QueryOptions we create a new instance of ODataQueryOptions<T>.

This causes some problems when the user calls it several times and makes changes on one of the instances as the customer expects the same instance to be returned every time he calls EntitySetController.QueryOptions.
Comments: Also, use the EdmModel and the information on the request to figure out the right type to use to create the ODataQueryOptions instead of using the generic type on the EntitySetController.

Closed Issue: UrilHelper's link generation should be case IN-sensitive when taking in tokens [504]

$
0
0
Following is the inconsistent experience currently.

Scenario1
---------
I have the following route(NOTE: the route tokens are all in CAPS...more realistic scenario is when users say 'Controller'...note the capital 'C'):
config.Routes.MapHttpRoute("Default", "{controller}/{action}/{id}", new { CONTROLLER = "SampleTests", ACTION = "GetString1", id = RouteParameter.Optional });

When i make a request like this : "http://localhost:9090/", it properly delivers it to the "SampleTests" controller's "GetString1" action.

Scenario2
---------
I am trying to generate a link at an ApiController's action. The route through which i arrived at the action is:
"http://localhost:9090/SampleTests/GetString2"

Doing the following at the action(NOTE: the route tokens are all in CAPS):
Url.Link("Default", new { CONTROLLER = "Greetings", ACTION = "SayHello" });

Expected:"http://localhost:9090/Greetings/SayHello"
Actual :"http://localhost:9090/SampleTests/GetString2"

Observation: in the incoming path we are not considering the case-sensitiveness of the route tokens, but during Url Link generation we are.

Comments: Verified

Closed Issue: Attribute routing should consider per-controller configuration based action selector [972]

$
0
0
Currently we always take the IHttpActionSelector implementation present on global configuration. We should consider taking it from Per-Controller configuration if present.

HelpPage, for example, currently uses per-controller configuration's action selector during help page generation. We should do the same for attribute routing:
```
private void ExploreRouteActions(IHttpRoute route, string localPath, HttpControllerDescriptor controllerDescriptor, Collection<ApiDescription> apiDescriptions)
{
ServicesContainer controllerServices = controllerDescriptor.Configuration.Services;
ILookup<string, HttpActionDescriptor> actionMappings = controllerServices.GetActionSelector().GetActionMapping(controllerDescriptor);
```

Just to check whether per-controller configuration based action selector could be used with attribute routing, I have tried creating custom action selector on a per-controller configuration and after modification to MapHttpAttributeRoutes to use the controller specific action selector, I noticed that attribute routing, help page and action selection happens based out of my custom action selector. so, it appears we could use action selector out of per-controller configuration.
Comments: Verified.

Closed Issue: Disambiguate actions correctly when they are overloaded by Enum types [312]

$
0
0
The details behind this issue can be found here:
http://forums.asp.net/post/5102466.aspx

Enum types by default are FromUri as it has a TypeConverter from string.
Comments: Verified.

Closed Issue: Batching scenario not working in Web host. [957]

$
0
0
I have been unable to make batching work in Web host scenarios with our latest code. I tried using Brad Wilson's batching sample from his blog post and also the HostedBatch sample in public asp.net samples.

This looks like a regression due to addition of the following check (in both GetRouteData & GetVirutalPath of HostedHttpRouteCollection)

```
if (httpContextBase.GetHttpRequestMessage() == null)
{
httpContextBase.SetHttpRequestMessage(request);
}
```

I receive the following error in case of an embedded batch request's processing:

--aefa68bf-368b-439e-b77e-fed0dc918f69
Content-Type: application/http; msgtype=response

HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8

__System.NotImplementedException: The method or operation is not implemented.__
at System.Web.HttpContextBase.get_Items()
at System.Web.Http.WebHost.Routing.HttpContextBaseExtensions.GetHttpRequestMessage(HttpContextBase context) in d:\Web
StackRuntime\Runtime\src\System.Web.Http.WebHost\Routing\HttpContextBaseExtensions.cs:line 18
at System.Web.Http.WebHost.Routing.HostedHttpRouteCollection.GetRouteData(HttpRequestMessage request) in d:\WebStackR
untime\Runtime\src\System.Web.Http.WebHost\Routing\HostedHttpRouteCollection.cs:line 83
at System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellat
ionToken) in d:\WebStackRuntime\Runtime\src\System.Web.Http\Dispatcher\HttpRoutingDispatcher.cs:line 67
at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Web.Http.HttpServer.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) in d:\WebSta
ckRuntime\Runtime\src\System.Web.Http\HttpServer.cs:line 157
at System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at BatchingAndAttributeRouting.BatchHandler.<SendAsync>d__0.MoveNext() in c:\Users\kichalla\Dropbox\SampleApps\Batchi
ngAndAttributeRouting\BatchHandler.cs:line 52

Repro:
1. Get the HostedBatch sample and run it. you should see it working.
2. Upgrade the nugget packages to MyGet nightly.
3. Run the sample, you should see 400 Bad Request for all the inner requests. If you debug you should see the above mentioned exception.
Comments: Verified.

Closed Issue: Batching handlers should dispose responses in case of excetpions [1011]

$
0
0
When a batch request is received in Web API, this request is spawn into multiple requests. When these requests are being executed one by one, there is a possibility that one of the request's processing could throw an exception(OperationCanceledException) or let's say one of the batch requests is malformed, in which case we need to dispose the responses which were previously successfully created.

Discussed with Yao about this.

Repro:
1. Use the UnbufferedODataBatchHandler in ODataServiceSample and launch the service.
2. Open Fiddler and go to Composer tab and then the Raw tab.
3. Copy the attached file's content in the Raw tab and click Execute. __Note__ that the last embedded request in the batch request doesn't have Content headers to it. This was intentional.
4. You should see the request fail with 500 Internal Server Error.
5. Its not easy to find if dispose is called on responses, but I concluded this by have some trace statements in ODataResponseItem's dispose method.

DefaultODataBatchHandler:
```
public override async Task<HttpResponseMessage> ProcessBatchAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
if (request == null)
{
throw Error.ArgumentNull("request");
}

cancellationToken.ThrowIfCancellationRequested();

ValidateRequest(request);

IList<ODataBatchRequestItem> subRequests = await ParseBatchRequestsAsync(request);

try
{
IList<ODataBatchResponseItem> responses = await ExecuteRequestMessagesAsync(subRequests, cancellationToken);
return await CreateResponseMessageAsync(responses, request);
}
finally
{
foreach (ODataBatchRequestItem subRequest in subRequests)
{
request.RegisterForDispose(subRequest.GetResourcesForDisposal());
request.RegisterForDispose(subRequest);
}
}
}

public virtual async Task<IList<ODataBatchResponseItem>> ExecuteRequestMessagesAsync(IEnumerable<ODataBatchRequestItem> requests, CancellationToken cancellationToken)
{
if (requests == null)
{
throw Error.ArgumentNull("requests");
}

cancellationToken.ThrowIfCancellationRequested();

IList<ODataBatchResponseItem> responses = new List<ODataBatchResponseItem>();
foreach (ODataBatchRequestItem request in requests)
{
responses.Add(await request.SendRequestAsync(Invoker, cancellationToken));
}

return responses;
}

```
Comments: Verified.

Closed Issue: ApiExplorer incorrectly assumes conflicts when a controller's action could be reached by multiple routes. [869]

$
0
0
I have a ValuesController and StudentsController in my application and following routes:

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

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

I see that ApiExplorer is not generating descriptions for values controller. It generates fine for StudentsController.

I debugged through this and noticed the problem is occurring in the following method of ApiExplorer.cs
```
// remove ApiDescription that will lead to ambiguous action matching.
private static Collection<ApiDescription> RemoveInvalidApiDescriptions(Collection<ApiDescription> apiDescriptions)
{
HashSet<string> duplicateApiDescriptionIds = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
HashSet<string> visitedApiDescriptionIds = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

foreach (ApiDescription description in apiDescriptions)
{
string apiDescriptionId = description.ID;
if (visitedApiDescriptionIds.Contains(apiDescriptionId))
{
duplicateApiDescriptionIds.Add(apiDescriptionId);
}
else
{
visitedApiDescriptionIds.Add(apiDescriptionId);
}
}

Collection<ApiDescription> filteredApiDescriptions = new Collection<ApiDescription>();
foreach (ApiDescription apiDescription in apiDescriptions)
{
string apiDescriptionId = apiDescription.ID;
if (!duplicateApiDescriptionIds.Contains(apiDescriptionId))
{
filteredApiDescriptions.Add(apiDescription);
}
}

return filteredApiDescriptions;
}
```
Comments: Verified.

Commented Issue: Razor code formatting is broken when using tabs in VS2012 MVC 4 [398]

$
0
0
When using "Keep tabs" instead of the default "Insert spaces", and running "Fomat document" (CTRL-E, CTRL-D) on in a .cshtml file with razor code any ifs inside other markup gets "mangled". I've attached a screenshot with a comparison of space and tab formatting.

Repro:
In Visual Studio 2012 (I'm using premium), create a new ASP.NET MVC 4 project (using the default web site template).
Open "Tools"->"Options"->"Text Editor"->"All Languages"->"Tabs" and set "Keep tabs" instead of "Insert spaces".
Open any view (.cshtml) and insert:
<div>
@if(true) {
}
</div>

Run format document (CTRL-E, CTRL-D).
Comments: Wondering if anyone has heard of any progress on this.

Commented Feature: Make the ApiControllerActionSelector more extensible [277]

$
0
0
The goal is to have the default action selector (ApiControllerActionSelector) expose some hooks or properties so that it's easier to customize.
Comments: A yes vote from me.

Created Unassigned: Provide an EmptyAuthenticationResult that signals the pipeline that there is no authentication information present on the request [1062]

$
0
0
When implementing an IAuthenticationFilter, in the AuthenticateAsync method you can return one of the out of the box implemented classes: SuccessfullAuthenticationResult or FailedAuthenticationResult to signal the result of the operation.
However, the possibles outcomes of the AuthenticateAsync method are really three:
Success: Meaning that the authentication information was present on the request and was correct.
Failure: Meaning that the authentication information was present on the request but was incorrect.
Empty: Meaning that there is no authentication information on the request.

In order to signal this third state, the user can return Task.FromResult(null), but this is confusing as there are classes for the other two states and there is no easy way to know that returning null will just work.
Its more clear to have an explicit class EmptyAuthenticationResult that the user can return when creating his own authentication filter.

The resulting implementation will look like in pseudocode:

```
public Task<IAuthenticationResult> AuthenticateAsync(params)
{
if(requestContainsAuthenticationInformation){
if(authenticationInfo)
{
return new SucessfulAuthentication(principal);
}
else
{
return new FailedAuthentication(error);
}
}
return new EmptyAuthenticationResult();
}
```

Commented Issue: Razor code formatting is broken when using tabs in VS2012 MVC 4 [398]

$
0
0
When using "Keep tabs" instead of the default "Insert spaces", and running "Fomat document" (CTRL-E, CTRL-D) on in a .cshtml file with razor code any ifs inside other markup gets "mangled". I've attached a screenshot with a comparison of space and tab formatting.

Repro:
In Visual Studio 2012 (I'm using premium), create a new ASP.NET MVC 4 project (using the default web site template).
Open "Tools"->"Options"->"Text Editor"->"All Languages"->"Tabs" and set "Keep tabs" instead of "Insert spaces".
Open any view (.cshtml) and insert:
<div>
@if(true) {
}
</div>

Run format document (CTRL-E, CTRL-D).
Comments: @johnmblack - As you can tell from the bug status it is planned to be addressed in our next release. We already know how to fix the formatting when you format using Ctrl-K-D, and we are looking at the auto formatting issue as well.

Commented Issue: Razor code formatting is broken when using tabs in VS2012 MVC 4 [398]

$
0
0
When using "Keep tabs" instead of the default "Insert spaces", and running "Fomat document" (CTRL-E, CTRL-D) on in a .cshtml file with razor code any ifs inside other markup gets "mangled". I've attached a screenshot with a comparison of space and tab formatting.

Repro:
In Visual Studio 2012 (I'm using premium), create a new ASP.NET MVC 4 project (using the default web site template).
Open "Tools"->"Options"->"Text Editor"->"All Languages"->"Tabs" and set "Keep tabs" instead of "Insert spaces".
Open any view (.cshtml) and insert:
<div>
@if(true) {
}
</div>

Run format document (CTRL-E, CTRL-D).
Comments: Thank you! What is confusing for me (newbie, I admit) is how the release numbers for this particular component relate to the MVC release numbers overall -- Does "5.0 RTM" mean that this is for MVC5 ? Or is this component on its own release numbering? -John

Created Unassigned: Support Rails ActiveModel::Serializer Pattern for JSON Output on WebAPIs [1063]

$
0
0
Many client side JavaScript libraries are built off the assumption that the REST services use the [ActiveModel::Serializer pattern](https://github.com/rails-api/active_model_serializers) for JSON data. It would be nice if their were built in support for this style of API in WebAPIs so client side libraries could be used without modification on both ASP.NET WebAPI and Rails services.

Created Unassigned: [Regression]Multipart parser not setting content length header on inner contents [1064]

$
0
0
Attached a repro.

__Issue__:
The below action is returning null when actually there is valid data in the content. The issue here is that the content header ‘Content-Length’ value is 0 even though the underlying stream length is actually greater than 0…since the content-length is 0, the deserialization thinks that there is no content to be deserialized and hence returns default value for the C# type(DataPack here) which is null.
```
[HttpPost("MultipartPost")]
public async Task<DataPack> MultipartPost()
{
MultipartMemoryStreamProvider provider = await Request.Content.ReadAsMultipartAsync();

HttpContent content = provider.Contents[0];

return await content.ReadAsAsync<DataPack>();
}
```

__Workaround__:
```
[HttpPost("MultipartPost")]
public async Task<DataPack> MultipartPost()
{
MultipartMemoryStreamProvider provider = await Request.Content.ReadAsMultipartAsync();

HttpContent content = provider.Contents[0];

// workaround
Stream stream = await content.ReadAsStreamAsync();
content.Headers.ContentLength = stream.Length;

return await content.ReadAsAsync<DataPack>();
}
```

Commented Issue: Razor code formatting is broken when using tabs in VS2012 MVC 4 [398]

$
0
0
When using "Keep tabs" instead of the default "Insert spaces", and running "Fomat document" (CTRL-E, CTRL-D) on in a .cshtml file with razor code any ifs inside other markup gets "mangled". I've attached a screenshot with a comparison of space and tab formatting.

Repro:
In Visual Studio 2012 (I'm using premium), create a new ASP.NET MVC 4 project (using the default web site template).
Open "Tools"->"Options"->"Text Editor"->"All Languages"->"Tabs" and set "Keep tabs" instead of "Insert spaces".
Open any view (.cshtml) and insert:
<div>
@if(true) {
}
</div>

Run format document (CTRL-E, CTRL-D).
Comments: The bug tracking numbering is based on the MVC releases but the individual components will have the following numbering: Razor/Web Pages V3 WebApi V2 MVC V5

Closed Issue: MQ: Don't disable warnings at the project level [613]

$
0
0
CS0618: We want the compiler to help us remember not to call obsolete methods. If there are specific cases where we need to do so, we should add suppressions at the source level (#pragma), not at the project level.

A number of projects disable CS1591 at the project level, which means the compiler won't help reminding to add XML doc comments for new code.

This work item also includes checking for any other project-level suppressions and fixing them too.
Viewing all 7215 articles
Browse latest View live


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