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

Edited Unassigned: RouteData not available to WebHost's buffer policy selector for attribute routing generated routes [1158]

$
0
0
__Scenario__:
User wishes to upload large files to a Web API service. He does not want these files to be buffered, so depending on the incoming request's route data (ex: controller, action), he either enables streamed or buffer mode.

__Issue__:
In the below code, "UserBufferInputStream" method isn't having any routedata available to perform the evaluation. This happens only for attribute routing generated routes as it goes through a certain path which conventional routes do not go through.

```
config.Services.Replace(typeof(IHostBufferPolicySelector), new CustomWebHostBufferPolicySelector());

public class CustomWebHostBufferPolicySelector : WebHostBufferPolicySelector
{
public override bool UseBufferedInputStream(object hostContext)
{
HttpContextBase contextBase = (HttpContextBase)hostContext;

RouteData routeData = contextBase.Request.RequestContext.RouteData;

object actions;
if (routeData.DataTokens != null && routeData.DataTokens.TryGetValue("actions", out actions))
{
//retrieve the controller name from action descriptors
}

return true;
}
}

```

__Workaround__:
A user could be returning just 'false' always without checking the route data. Web API pipeline works just fine if the request is in streamed mode, but currently the problem is with __bug #1136__, which breaks MVC if we do so. Actually, I started out the current scenario as a workaround for that bug.

Edited Unassigned: RouteData not available to WebHost's buffer policy selector in certain scenarios [1158]

$
0
0
__Scenario__:
User wishes to upload large files to a Web API service. He does not want these files to be buffered, so depending on the incoming request's route data (ex: controller, action), he either enables streamed or buffer mode.

__Issue__:
In the below code, "UserBufferInputStream" method isn't having any routedata available to perform the evaluation. This is happening in following scenarios :

1. When attribute routing is used.
2. When conventional routing is used and the conventional route has route constraints.

```
config.Services.Replace(typeof(IHostBufferPolicySelector), new CustomWebHostBufferPolicySelector());

public class CustomWebHostBufferPolicySelector : WebHostBufferPolicySelector
{
public override bool UseBufferedInputStream(object hostContext)
{
HttpContextBase contextBase = (HttpContextBase)hostContext;

RouteData routeData = contextBase.Request.RequestContext.RouteData;

object actions;
if (routeData.DataTokens != null && routeData.DataTokens.TryGetValue("actions", out actions))
{
//retrieve the controller name from action descriptors
}

return true;
}
}

```

__Workaround__:
A user could be returning just 'false' always without checking the route data. Web API pipeline works just fine if the request is in streamed mode, but currently the problem is with __bug #1136__, which breaks MVC if we do so. Actually, I started out the current scenario as a workaround for that bug.

Edited Unassigned: Razor V2 & V3-beta2 : Issue with parsing bool value in HTML tag attribute [1159]

$
0
0
From Razor V2 onwards, I have noticed issue while parsing bool value with HTML tag attribute. Issue reproduced only when we are parsing bool value as HTML tag attribute. Please have a look at below code snippet and output i.e. rendered HTML.

__Code Snippet__
@{
bool trueVal = true;
bool falseVal = false;
}
@trueVal | @falseVal | <input type="text" value="@trueVal" /> | <input type="text" value="@falseVal" />

__Razor V1 Output__
True | False | <input type="text" value="True" /> | <input type="text" value="False" />

__Razor V2 & V3-beta2 Output__
True | False | <input type="text" value="value" /> | <input type="text" />
In above V2 & V3-beta2 output we can see that it is rendering __value="value" for bool True, while for bool False it is not rendering value attribute at all__ Ideally it should be value="True" and value="False" respectively.

__UPDATE__
Ironically it is __working fine for data-*** attribute__ in Razor V2 & V3-beta2 as well!

Edited Unassigned: Razor V2 & V3-beta2 : Issue with parsing bool value in HTML tag attribute [1159]

$
0
0
From Razor V2 onwards, I have noticed issue while parsing bool value with HTML tag attribute. Issue reproduced only when we are parsing bool value as HTML tag attribute. Please have a look at below code snippet and output i.e. rendered HTML.

__Code Snippet__
@{
bool trueVal = true;
bool falseVal = false;
}
@trueVal | @falseVal | <input type="text" value="@trueVal" /> | <input type="text" value="@falseVal" />

__Razor V1 Output__
True | False | <input type="text" value="True" /> | <input type="text" value="False" />

__Razor V2 & V3-beta2 Output__
True | False | <input type="text" value="value" /> | <input type="text" />
In above V2 & V3-beta2 output we can see that it is rendering __value="value" for bool True, while for bool False it is not rendering value attribute at all__ Ideally it should be value="True" and value="False" respectively.

__UPDATE__
Ironically it is __working fine for data-*** attribute__ in Razor V2 & V3-beta2 as well! But I found that this is due to conditional attribute introduced in Razor V2. And also found that similar issue is closed earlier as will not fix. [https://aspnetwebstack.codeplex.com/workitem/474](https://aspnetwebstack.codeplex.com/workitem/474)

Created Unassigned: In MVC attribute routing, ignoring route prefix fails when '~/' template is used [1160]

$
0
0
__Scenario__:
User likes to make the HomeController's Index as the default view when anyone visits like "http://mysite.com"

__Issue__:
I am receiving the following validation error for the following controller:

__The route template '~/' on the action named 'Index' on the controller named 'Home' cannot begin or end with a forward slash.__

```
[RoutePrefix("Home")]
public class HomeController : Controller
{
//[HttpGet("~/")] //NOTE: Does not work
HttpGet("")]
[HttpGet("Index")]
public ActionResult Index()
{
return View();
}

[HttpGet("About")]
public ActionResult About()
{
ViewBag.Message = "About page";

return View();
}

[HttpGet("Contact")]
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";

return View();
}
}
```

__Workaround__:
User can remove the route prefix and instead do the following:
```
public class HomeController : Controller
{
[HttpGet("")]
[HttpGet("Home")]
[HttpGet("Home/Index")]
public ActionResult Index()
{
return View();
}

```

Edited Issue: Web Api attribute routing is adding NonAction decorated method to route collection [1151]

$
0
0
__Scenario__:
A user sometimes would like to keep some methods public in his controller but would not like it to be invoked by end users, so he decorates it with [NonAction] attribute.

__Issue__:
In the following scenario, a route is being added to the route collection:
```
[RoutePrefix("api/values")]
public class ValuesController : ApiController
{
[NonAction]
public IEnumerable<string> GetAllValues()
{
return new string[] { "value1", "value2" };
}
}
```
Following would be how the route could look like in the route collection:
config.Routes.MapHttpRoute("routeName", "api/values", new { }, new { }, new { actions = [Values.GetAllValues()] });

__Workaround__:
Create custom route builder deriving from the default one. Override one of the "BuildHttpRoute" methods which provides access to the action descriptor and using it you can check to see if there are any NonAction attributes decorated and if present, ignore adding the route to the route collection.

__UPDATE__:
I have tried the above workaround, but I am currently receiving an exception. __Should we allow returning null from route builder?__ I cannot think of other scenarios where users might want to do this.

```
public override IHttpRoute BuildHttpRoute(string routeTemplate, IEnumerable<HttpMethod> httpMethods,
IEnumerable<ReflectedHttpActionDescriptor> actions)
{
ReflectedHttpActionDescriptor nonActionDescriptor = actions.FirstOrDefault();

if (nonActionDescriptor != null)
{
Collection<NonActionAttribute> nonActionAttribs = nonActionDescriptor.GetCustomAttributes<NonActionAttribute>(inherit: false);

if (nonActionAttribs.Count > 0)
{
return null;
}
}

return base.BuildHttpRoute(routeTemplate, httpMethods, actions);
}
```

__Exception__:
System.ArgumentNullException occurred
HResult=-2147467261
Message=Value cannot be null.
Parameter name: route
Source=System.Web.Http
ParamName=route
StackTrace:
at System.Web.Http.HttpRouteCollection.Add(String name, IHttpRoute route) in c:\WebstackRuntime\Runtime\src\System.Web.Http\HttpRouteCollection.cs:line 167
InnerException:

Commented Issue: Web Api attribute routing is adding NonAction decorated method to route collection [1151]

$
0
0
__Scenario__:
A user sometimes would like to keep some methods public in his controller but would not like it to be invoked by end users, so he decorates it with [NonAction] attribute.

__Issue__:
In the following scenario, a route is being added to the route collection:
```
[RoutePrefix("api/values")]
public class ValuesController : ApiController
{
[NonAction]
public IEnumerable<string> GetAllValues()
{
return new string[] { "value1", "value2" };
}
}
```
Following would be how the route could look like in the route collection:
config.Routes.MapHttpRoute("routeName", "api/values", new { }, new { }, new { actions = [Values.GetAllValues()] });

__Workaround__:
Create custom route builder deriving from the default one. Override one of the "BuildHttpRoute" methods which provides access to the action descriptor and using it you can check to see if there are any NonAction attributes decorated and if present, ignore adding the route to the route collection.

__UPDATE__:
I have tried the above workaround, but I am currently receiving an exception. __Should we allow returning null from route builder?__ I cannot think of other scenarios where users might want to do this.

```
public override IHttpRoute BuildHttpRoute(string routeTemplate, IEnumerable<HttpMethod> httpMethods,
IEnumerable<ReflectedHttpActionDescriptor> actions)
{
ReflectedHttpActionDescriptor nonActionDescriptor = actions.FirstOrDefault();

if (nonActionDescriptor != null)
{
Collection<NonActionAttribute> nonActionAttribs = nonActionDescriptor.GetCustomAttributes<NonActionAttribute>(inherit: false);

if (nonActionAttribs.Count > 0)
{
return null;
}
}

return base.BuildHttpRoute(routeTemplate, httpMethods, actions);
}
```

__Exception__:
System.ArgumentNullException occurred
HResult=-2147467261
Message=Value cannot be null.
Parameter name: route
Source=System.Web.Http
ParamName=route
StackTrace:
at System.Web.Http.HttpRouteCollection.Add(String name, IHttpRoute route) in c:\WebstackRuntime\Runtime\src\System.Web.Http\HttpRouteCollection.cs:line 167
InnerException:

Comments: Fixed: https://aspnetwebstack.codeplex.com/SourceControl/changeset/842d9a9de839f6482686ea73de5c2d230222f6a3

Commented Issue: Web Api attribute routing is adding NonAction decorated method to route collection [1151]

$
0
0
__Scenario__:
A user sometimes would like to keep some methods public in his controller but would not like it to be invoked by end users, so he decorates it with [NonAction] attribute.

__Issue__:
In the following scenario, a route is being added to the route collection:
```
[RoutePrefix("api/values")]
public class ValuesController : ApiController
{
[NonAction]
public IEnumerable<string> GetAllValues()
{
return new string[] { "value1", "value2" };
}
}
```
Following would be how the route could look like in the route collection:
config.Routes.MapHttpRoute("routeName", "api/values", new { }, new { }, new { actions = [Values.GetAllValues()] });

__Workaround__:
Create custom route builder deriving from the default one. Override one of the "BuildHttpRoute" methods which provides access to the action descriptor and using it you can check to see if there are any NonAction attributes decorated and if present, ignore adding the route to the route collection.

__UPDATE__:
I have tried the above workaround, but I am currently receiving an exception. __Should we allow returning null from route builder?__ I cannot think of other scenarios where users might want to do this.

```
public override IHttpRoute BuildHttpRoute(string routeTemplate, IEnumerable<HttpMethod> httpMethods,
IEnumerable<ReflectedHttpActionDescriptor> actions)
{
ReflectedHttpActionDescriptor nonActionDescriptor = actions.FirstOrDefault();

if (nonActionDescriptor != null)
{
Collection<NonActionAttribute> nonActionAttribs = nonActionDescriptor.GetCustomAttributes<NonActionAttribute>(inherit: false);

if (nonActionAttribs.Count > 0)
{
return null;
}
}

return base.BuildHttpRoute(routeTemplate, httpMethods, actions);
}
```

__Exception__:
System.ArgumentNullException occurred
HResult=-2147467261
Message=Value cannot be null.
Parameter name: route
Source=System.Web.Http
ParamName=route
StackTrace:
at System.Web.Http.HttpRouteCollection.Add(String name, IHttpRoute route) in c:\WebstackRuntime\Runtime\src\System.Web.Http\HttpRouteCollection.cs:line 167
InnerException:

Comments: Wrong changeset. Here's the right one: https://aspnetwebstack.codeplex.com/SourceControl/changeset/32257df6f25fb5b14c09f5d38a66163998352e2a

Edited Unassigned: In MVC attribute routing, ignoring route prefix fails when '~/' template is used [1160]

$
0
0
__Scenario__:
User likes to make the HomeController's Index as the default view when anyone visits like "http://mysite.com"

__Issue__:
I am receiving the following validation error for the following controller:

__The route template '~/' on the action named 'Index' on the controller named 'Home' cannot begin or end with a forward slash.__

```
[RoutePrefix("Home")]
public class HomeController : Controller
{
//[HttpGet("~/")] //NOTE: Does not work
HttpGet("")]
[HttpGet("Index")]
public ActionResult Index()
{
return View();
}

[HttpGet("About")]
public ActionResult About()
{
ViewBag.Message = "About page";

return View();
}

[HttpGet("Contact")]
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";

return View();
}
}
```

__Workaround__:
User can remove the route prefix and instead do the following:
```
public class HomeController : Controller
{
[HttpGet("")]
[HttpGet("Home")]
[HttpGet("Home/Index")]
public ActionResult Index()
{
return View();
}

```

Edited Unassigned: In MVC attribute routing, ignoring route prefix fails when '~/' template is used [1160]

$
0
0
__Scenario__:
User likes to make the HomeController's Index as the default view when anyone visits like "http://mysite.com"

__Issue__:
I am receiving the following validation error for the following controller:

__The route template '~/' on the action named 'Index' on the controller named 'Home' cannot begin or end with a forward slash.__

```
[RoutePrefix("Home")]
public class HomeController : Controller
{
//[HttpGet("~/")] //NOTE: Does not work
HttpGet("")]
[HttpGet("Index")]
public ActionResult Index()
{
return View();
}

[HttpGet("About")]
public ActionResult About()
{
ViewBag.Message = "About page";

return View();
}

[HttpGet("Contact")]
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";

return View();
}
}
```

__Workaround__:
User can remove the route prefix and instead do the following:
```
public class HomeController : Controller
{
[HttpGet("")]
[HttpGet("Home")]
[HttpGet("Home/Index")]
public ActionResult Index()
{
return View();
}

```

Commented Unassigned: In MVC attribute routing, ignoring route prefix fails when '~/' template is used [1160]

$
0
0
__Scenario__:
User likes to make the HomeController's Index as the default view when anyone visits like "http://mysite.com"

__Issue__:
I am receiving the following validation error for the following controller:

__The route template '~/' on the action named 'Index' on the controller named 'Home' cannot begin or end with a forward slash.__

```
[RoutePrefix("Home")]
public class HomeController : Controller
{
//[HttpGet("~/")] //NOTE: Does not work
HttpGet("")]
[HttpGet("Index")]
public ActionResult Index()
{
return View();
}

[HttpGet("About")]
public ActionResult About()
{
ViewBag.Message = "About page";

return View();
}

[HttpGet("Contact")]
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";

return View();
}
}
```

__Workaround__:
User can remove the route prefix and instead do the following:
```
public class HomeController : Controller
{
[HttpGet("")]
[HttpGet("Home")]
[HttpGet("Home/Index")]
public ActionResult Index()
{
return View();
}

```
Comments: Fixed: https://aspnetwebstack.codeplex.com/SourceControl/changeset/a53db58412c52fce69a1f7c67d41b0f0f9b6a61f

Edited Issue: In MVC attribute routing, ignoring route prefix fails when '~/' template is used [1160]

$
0
0
__Scenario__:
User likes to make the HomeController's Index as the default view when anyone visits like "http://mysite.com"

__Issue__:
I am receiving the following validation error for the following controller:

__The route template '~/' on the action named 'Index' on the controller named 'Home' cannot begin or end with a forward slash.__

```
[RoutePrefix("Home")]
public class HomeController : Controller
{
//[HttpGet("~/")] //NOTE: Does not work
HttpGet("")]
[HttpGet("Index")]
public ActionResult Index()
{
return View();
}

[HttpGet("About")]
public ActionResult About()
{
ViewBag.Message = "About page";

return View();
}

[HttpGet("Contact")]
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";

return View();
}
}
```

__Workaround__:
User can remove the route prefix and instead do the following:
```
public class HomeController : Controller
{
[HttpGet("")]
[HttpGet("Home")]
[HttpGet("Home/Index")]
public ActionResult Index()
{
return View();
}

```

Edited Task: MQ: Automate cleanup of old builds [1162]

$
0
0
Add a scheduled task to remove builds older than three months.

Edited Issue: Consider changing the default value for MaxExpansionDepth to be more permisive [1161]

$
0
0
The default value for MaxExpansionDepth in Web API is set to 1. Although this works on most of the cases, having a default expansion value of two is much more reasonable, as it can cover scenarios like a client querying for a Customer, it's related Orders and the Details for those orders.

In the Web API preview, there wasn't support for nested server pagination of a IQueryable, so this limit had to be very conservative as it could cause a serious performance penalty on the service As nested pagination has been implemented for RTM, it makes sense to be more permissive with this limit, as for example, if we stablish a page size of 10, and an expansion depth of 2, the maximum number of objects that a client could retrieve in one request would be 1110 considering he sends a query like query?$expand=Orders/Details

Closed Unassigned: Razor V2 & V3-beta2 : Issue with parsing bool value in HTML tag attribute [1159]

$
0
0
From Razor V2 onwards, I have noticed issue while parsing bool value with HTML tag attribute. Issue reproduced only when we are parsing bool value as HTML tag attribute. Please have a look at below code snippet and output i.e. rendered HTML.

__Code Snippet__
@{
bool trueVal = true;
bool falseVal = false;
}
@trueVal | @falseVal | <input type="text" value="@trueVal" /> | <input type="text" value="@falseVal" />

__Razor V1 Output__
True | False | <input type="text" value="True" /> | <input type="text" value="False" />

__Razor V2 & V3-beta2 Output__
True | False | <input type="text" value="value" /> | <input type="text" />
In above V2 & V3-beta2 output we can see that it is rendering __value="value" for bool True, while for bool False it is not rendering value attribute at all__ Ideally it should be value="True" and value="False" respectively.

__UPDATE__
Ironically it is __working fine for data-*** attribute__ in Razor V2 & V3-beta2 as well! But I found that this is due to conditional attribute introduced in Razor V2. And also found that similar issue is closed earlier as will not fix. [https://aspnetwebstack.codeplex.com/workitem/474](https://aspnetwebstack.codeplex.com/workitem/474)
Comments: Hi Nandip, This was a deliberate behavior change in Razor to allow supporting conditional attributes. The reason that data-*** are not affected is that Razor deliberately ignores those for conditional attributes. We recommend calling .ToString() on values to ensure that they are explicitly written out as-is. Thanks, Eilon

Edited Unassigned: Move HttpError to the System.Net.Http.Formatting.dll [1156]

$
0
0
So that clients that want to deserialize HttpError do not have to take a dependency on the server dll i.e System.Web.Http.dll

Edited Issue: Unbuffered input streams don't work correctly on web host [1136]

$
0
0
Returning false from IHostBufferPolicySelector.UseBufferedInputStream on web host breakes Web API + MVC side-by-side, at least in some scenarios.

Consider an MVC controller with the following code:
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Test = new StreamReader(Request.InputStream).ReadToEnd();
return View();
}
}

Then, have in the same web app the following Web API setup:
public static void Register(HttpConfiguration config)
{
config.Services.Replace(typeof(IHostBufferPolicySelector), new BufferOutputOnlyPolicySelector());
config.Routes.Add("Unused", new CustomRoute());
}

private class BufferOutputOnlyPolicySelector : IHostBufferPolicySelector
{
public bool UseBufferedInputStream(object hostContext)
{
return false;
}

public bool UseBufferedOutputStream(System.Net.Http.HttpResponseMessage response)
{
return true;
}
}

private class CustomRoute : IHttpRoute
{
public IDictionary<string, object> Constraints
{
get { return null; }
}

public IDictionary<string, object> DataTokens
{
get { return null; }
}

public IDictionary<string, object> Defaults
{
get { return null; }
}

public IHttpRouteData GetRouteData(string virtualPathRoot, System.Net.Http.HttpRequestMessage request)
{
return null;
}

public IHttpVirtualPathData GetVirtualPath(System.Net.Http.HttpRequestMessage request, IDictionary<string, object> values)
{
return null;
}

public System.Net.Http.HttpMessageHandler Handler
{
get { return null; }
}

public string RouteTemplate
{
get { return null; }
}
}

Then, try viewing the MVC page. You'll find that Web API routing broke MVC access to the page.

The only reason the CustomRoute is needed for the repro is some (apparent) optimizations around HostedHttpRoute that avoid creating an HttpRequestMessage. I believe adding a route constraint will also trigger the bug.

A possible solution is not to provide access to the input stream during Web API routing. (Note that the bug repros even when the input stream is not accessed during routing; merely making it available to be accessed causes this bug.)

Edited Issue: RouteData not available to WebHost's buffer policy selector in certain scenarios [1158]

$
0
0
__Scenario__:
User wishes to upload large files to a Web API service. He does not want these files to be buffered, so depending on the incoming request's route data (ex: controller, action), he either enables streamed or buffer mode.

__Issue__:
In the below code, "UserBufferInputStream" method isn't having any routedata available to perform the evaluation. This is happening in following scenarios :

1. When attribute routing is used.
2. When conventional routing is used and the conventional route has route constraints.

```
config.Services.Replace(typeof(IHostBufferPolicySelector), new CustomWebHostBufferPolicySelector());

public class CustomWebHostBufferPolicySelector : WebHostBufferPolicySelector
{
public override bool UseBufferedInputStream(object hostContext)
{
HttpContextBase contextBase = (HttpContextBase)hostContext;

RouteData routeData = contextBase.Request.RequestContext.RouteData;

object actions;
if (routeData.DataTokens != null && routeData.DataTokens.TryGetValue("actions", out actions))
{
//retrieve the controller name from action descriptors
}

return true;
}
}

```

__Workaround__:
A user could be returning just 'false' always without checking the route data. Web API pipeline works just fine if the request is in streamed mode, but currently the problem is with __bug #1136__, which breaks MVC if we do so. Actually, I started out the current scenario as a workaround for that bug.

Edited Issue: TransferEncodingChunked=true doesn't work on WebHost [1124]

$
0
0
When setting response.Headers.TransferEncodingChunked, the response doesn't get chunked, and a client (Fiddler) will fail trying to read the response.

Repro 1:
public HttpResponseMessage Get()
{
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
response.Headers.TransferEncodingChunked = true;
response.RequestMessage = Request;
return response;
}

Repro 2:
public HttpResponseMessage Get()
{
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
response.Content = new LazyContent();
response.Headers.TransferEncodingChunked = true;
response.RequestMessage = Request;
return response;
}

public class LazyContent : HttpContent
{
protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)
{
stream.WriteByte(0);
return Task.FromResult<object>(null);
}

protected override bool TryComputeLength(out long length)
{
length = 0;
return false;
}
}

Edited Issue: Post error: Either BinaryRead, Form, Files, or InputStream was accessed before the internal storage [1132]

$
0
0
See full [question in Stackoverflow](http://stackoverflow.com/questions/17602845/post-error-either-binaryread-form-files-or-inputstream-was-accessed-before-t)

After performing the downgrade webapi, it worked! But now without support for $expand and $select.

It seems that [this commit](https://aspnetwebstack.codeplex.com/SourceControl/changeset/0678d3e314c08403e1c9584cd08846b045ad5f5f) generated this error. (Thanks [JimmiTh](http://chat.stackoverflow.com/users/1169696/jimmith) and [Kiran Challa](http://chat.stackoverflow.com/users/1184056/kiran-challa))
Viewing all 7215 articles
Browse latest View live


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