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

Commented 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))
Comments: This was fixed when we reverted the offending changeset.

Commented Issue: HttpResponseException doesn't work in custom IHttpRoute implementation [387]

$
0
0
I have a custom IHttpRoute implementation for doing some custom routing. I want to throw a 400 (bad request) sometimes. I tried to do a "throw new HttpResponseException()" in my code but the client always receives a 500.
Comments: [Fixed](https://aspnetwebstack.codeplex.com/SourceControl/changeset/0a11d4dd907f651d3f05d3d966508c19b6517bc1).

Edited Issue: HttpResponseException doesn't work in custom IHttpRoute implementation [387]

$
0
0
I have a custom IHttpRoute implementation for doing some custom routing. I want to throw a 400 (bad request) sometimes. I tried to do a "throw new HttpResponseException()" in my code but the client always receives a 500.

Edited Issue: Methods with matrix parameters are not shown in help page [1122]

$
0
0
Our team decided to use standard query parameters in URIs only for sorting and paging and other non filtering actions on resources. For filtering we want to use matrix parameters.
Since it is not guaranteed that query parameters are being cached, matrix parameters should be used where applicable. But when using matrix parameters the help page wont show these requests.

Example:

```
/// <summary>
/// Get customers
/// </summary>
/// <param name="name">Name of the customer.</param>
/// <param name="surname">Surname of the customer.</param>
/// <returns>Returns a list of customers.</returns>
[HttpGet("api/customers;name={name};surname={surname}")]
public IEnumerable<Customer> GetByFilter(string name, string surname)
{
...
}
```

Instead of:
```
/// <summary>
/// Get customers
/// </summary>
/// <param name="name">Name of the customer.</param>
/// <param name="surname">Surname of the customer.</param>
/// <returns>Returns a list of customers.</returns>
[HttpGet("api/customers?name={name?}&surname={surname?}")]
public IEnumerable<Customer> GetByFilter(string name, string surname)
{
...
}
```

Kind regards,
Andy

Commented Issue: Methods with matrix parameters are not shown in help page [1122]

$
0
0
Our team decided to use standard query parameters in URIs only for sorting and paging and other non filtering actions on resources. For filtering we want to use matrix parameters.
Since it is not guaranteed that query parameters are being cached, matrix parameters should be used where applicable. But when using matrix parameters the help page wont show these requests.

Example:

```
/// <summary>
/// Get customers
/// </summary>
/// <param name="name">Name of the customer.</param>
/// <param name="surname">Surname of the customer.</param>
/// <returns>Returns a list of customers.</returns>
[HttpGet("api/customers;name={name};surname={surname}")]
public IEnumerable<Customer> GetByFilter(string name, string surname)
{
...
}
```

Instead of:
```
/// <summary>
/// Get customers
/// </summary>
/// <param name="name">Name of the customer.</param>
/// <param name="surname">Surname of the customer.</param>
/// <returns>Returns a list of customers.</returns>
[HttpGet("api/customers?name={name?}&surname={surname?}")]
public IEnumerable<Customer> GetByFilter(string name, string surname)
{
...
}
```

Kind regards,
Andy
Comments: Yao - While we don't intend to support matrix URIs completely, it does seem that the first example should show up properly in the help page.

Closed Unassigned: JsonContractResolver should use Default SerializerSettings [1104]

$
0
0
In JsonMediaTypeFormatter, JsonContractResolver is set as DefaultContractResolver, Which calls ConfigureProperty Method, Which should set Default SerializerSettings from JsonMediaTypeFormatter,
because of which DefaultValueHandling, NullValueHandling, don't work at all.

private void ConfigureProperty(MemberInfo member, JsonProperty property)
{
if ((this._formatter.RequiredMemberSelector != null) && this._formatter.RequiredMemberSelector.IsRequiredMember(member))
{
property.Required = Required.AllowNull;
property.DefaultValueHandling = 0;
property.NullValueHandling = 0;
}
else
{
property.Required = Required.Default;
}
}








Comments: Hi, We are still unable to reproduce this issue per your description. If you are able to come up with a repro for this please attach it to the bug and reactivate. Thanks, Eilon

Created Unassigned: Invalid Content-Type header value results in a 415 [1167]

$
0
0
Content-Type: multipart/related; type=image/jpeg; boundary=abc

The above is invalid because the "/" is invalid in image/jpeg. type="image/jpeg" should be used

I expect a 400 and observe that request.Content.Headers does not contain Content-Type or has a null value for Content-Type (I'm not sure which), which results in a 415

Created Unassigned: request.Content.ReadAsMultipartAsync() throws an InvalidOperationException if a part has two Content-Type headers [1168]

$
0
0
If a part of a multipart message contains two Content-Type headers, request.Content.ReadAsMultipartAsync() throws the following:

System.InvalidOperationException: Error parsing MIME multipart body part header byte 115 of data segment System.Byte[]. at System.Net.Http.Formatting.Parsers.MimeMultipartBodyPartParser.<ParseBuffer>d__0.MoveNext() at System.Net.Http.HttpContentMultipartExtensions.MoveNextPart(MultipartAsyncContext context)

I expect a 400 in this case.

Commented Unassigned: ASP.NET WebPages 2 - Validation bug [1120]

$
0
0

Hi, the validation does not seem to work correctly in ASP.NET WebPages 2. I created a form and then used the RenderPage method to render that page into another page however on submit the validation does not show, but the data inside the fields is preserved (If you use the Value attribute on HTML elements). I posted the issue on here as well:

http://forums.asp.net/t/1916968.aspx/1?Contact+Form+validation+not+showing+

I think this is the best place to raise the issue.
Comments: Hi RazorKnight, The code for the RazorC CMS is rather large so we are having difficulty reproducing this. Can you attach to this issue a simple (under 100 lines) repro that demonstrates the issue? Thanks!

Edited Issue: MVC attribute routing fails for multiple routes with the same URL, and no specific RouteName set. [1146]

$
0
0
__Scenario__:
User decorates the controller and actions with attributed routes and expects the applicaiton to work.

__Issue__:
Consider the following two actions in AccountController(shortened for brevity):
```
[RoutePrefix("Account")]
public class AccountController : Controller
{
//
// GET: /Account/Register
[AllowAnonymous]
[HttpGet("Register")]
public ActionResult Register()


//
// POST: /Account/Register
[HttpPost("Register")]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Register(RegisterViewModel model)
}
```
After the above changes, when the application is launched, we currently get the following
__Error__:
"A route named 'Account/Register' is already in the route collection. Route names must be unique.
Parameter name: name"

__Expected__:
The above error should not be occuring and the application should be launched successfully.

__Reason__:
In MVC, it appears that most of the Url link generation happens via the "Url.Action" or "Html.Actionlink" helpers, where users can specify action name, controller name etc. Since these helpers are used more commonly than "Url.RouteUrl" which expects a route name, we should not force the users to supply a unique route name upfront. We should generate unique names automatically just like how Web API's attribute routing works.

Even in Web API, we do not expect the users to depend on our uniquely generated names to generate links. If indeed they would like to have a friendly name for a particular route, they are expected to explicitly supply them. This way at least we do not provide a bad user experience upfront like currently MVC attribute routing does.

Commented Issue: MVC attribute routing fails for multiple routes with the same URL, and no specific RouteName set. [1146]

$
0
0
__Scenario__:
User decorates the controller and actions with attributed routes and expects the applicaiton to work.

__Issue__:
Consider the following two actions in AccountController(shortened for brevity):
```
[RoutePrefix("Account")]
public class AccountController : Controller
{
//
// GET: /Account/Register
[AllowAnonymous]
[HttpGet("Register")]
public ActionResult Register()


//
// POST: /Account/Register
[HttpPost("Register")]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Register(RegisterViewModel model)
}
```
After the above changes, when the application is launched, we currently get the following
__Error__:
"A route named 'Account/Register' is already in the route collection. Route names must be unique.
Parameter name: name"

__Expected__:
The above error should not be occuring and the application should be launched successfully.

__Reason__:
In MVC, it appears that most of the Url link generation happens via the "Url.Action" or "Html.Actionlink" helpers, where users can specify action name, controller name etc. Since these helpers are used more commonly than "Url.RouteUrl" which expects a route name, we should not force the users to supply a unique route name upfront. We should generate unique names automatically just like how Web API's attribute routing works.

Even in Web API, we do not expect the users to depend on our uniquely generated names to generate links. If indeed they would like to have a friendly name for a particular route, they are expected to explicitly supply them. This way at least we do not provide a bad user experience upfront like currently MVC attribute routing does.

Comments: Fixed: https://aspnetwebstack.codeplex.com/SourceControl/changeset/966245ac71d79f785d559d651779ee99e0f1bd12

Commented Unassigned: ASP.NET WebPages 2 - Validation bug [1120]

$
0
0

Hi, the validation does not seem to work correctly in ASP.NET WebPages 2. I created a form and then used the RenderPage method to render that page into another page however on submit the validation does not show, but the data inside the fields is preserved (If you use the Value attribute on HTML elements). I posted the issue on here as well:

http://forums.asp.net/t/1916968.aspx/1?Contact+Form+validation+not+showing+

I think this is the best place to raise the issue.
Comments: __EDIT: Sorry i can't attache the file this service is really slow, see code below__ HI the issue is with ASP.NET WebPages 2 Validation Class. Please see file attached to reproduce the issue do following: Create a new WebPages site copy the file I attached and run it. Submit the form, you will see the validation work. However, create a new file and using the RenderPage method render the file I attached, on submit the validation will not show. Another user raised this a few days ago: http://forums.asp.net/t/1924503.aspx/1?Validation+will+not+work+if+a+page+is+being+rendered+by+RenderPage+on+other+page CODE ``` @{ //THIS IS A SIMPLE FORM, RUN THIS PAGE AS A STANDALONE PAGE WITHOUT RAZORC AND YOU WILL SEE IT WORK. //HOWEVER IF YOU CALL IT USING THE RENDERPAGE METHOD THEN THE VALIDATION DOES NOT SHOW. var FullName = ""; var Age = ""; if (IsPost) { FullName = Request["FullName"]; Age = Request["Age"]; Validation.RequireFields("FullName", "Age"); Validation.Add("Age", Validator.Integer() ); Validation.Add("FullName", Validator.StringLength(20, 5) ); if (Validation.IsValid()) { <p>Welcome @FullName, you're @Age years old.</p> } } } <form method="post"> @Html.ValidationSummary(true) <div> <label>FullName</label> <input type="text" name="FullName"/> @Html.ValidationMessage("FullName") </div> <div> <label>Age</label> <input type="text" name="Age"/> @Html.ValidationMessage("Age") </div> <input type="submit"/> </form> ```

Commented Issue: Razor bug parsing HTML [710]

$
0
0
Razor in MVC has a bug when parsing HTML comments with an apostrophe in them. The engine throws an "Expected }" exception.

Below is an example on how to reproduce this issue in the default MVC 4 application with VS 2012. Just add the following a comment with an apostrophe to the @section featured {} in the default.cshtml. Remove the apostrophe from the comment and it works OK.

@section featured {
<!-- hello world it's not cool -->
<section class="featured">
<div class="content-wrapper">
<hgroup class="title">
<h1>@ViewBag.Title.</h1>
<h2>@ViewBag.Message</h2>
</hgroup>
<p>...</p>
</div>
</section>
}

http://stackoverflow.com/a/13864352/446681
Comments: The description above, and the commit message for the fix, both mention that this occurs for code inside a @section. If a comment OUTSIDE of a section contains an apostrophe, then problems still occur, but no warning is generated by the compiler. The manifestation I see is that resolution of ~/path/to/your/file URL's does not take place, and the ~ is output to the client verbatim. (SEE WORK ITEM 933). Please can you confirm that the fix also resolves the issue when the offending comment is not inside a @section directive?

Closed Feature: We should open up the configuration.Services to allow user register their custom services [873]

$
0
0
Today if one tries to add a custom service to the configuration.Services bag, it will throw exception saying that it does not support unknown services.

We should open this up so that people don't have to use configuration.Property bag to store those config wide settings. Also, because we will use DI first, custom service type will get the benefit.
Comments: Comment from RaghuRam: This bug was created during OData V1 time frame when we said “no core runtime changes”. OData had to add some custom extensibility points at the config level that time and our service container is not really designed for that. We had to use configuration.Properties to store these custom services and this idea seemed good at that time. We no longer have that problem now (inability to modify runtime). So, this bug is not relevant anymore. Also, opening up configuration.Services for general purpose DI would cause more confusion regarding scoping and caching as mentioned in the bug’s comments.

Commented Issue: Razor bug parsing HTML [710]

$
0
0
Razor in MVC has a bug when parsing HTML comments with an apostrophe in them. The engine throws an "Expected }" exception.

Below is an example on how to reproduce this issue in the default MVC 4 application with VS 2012. Just add the following a comment with an apostrophe to the @section featured {} in the default.cshtml. Remove the apostrophe from the comment and it works OK.

@section featured {
<!-- hello world it's not cool -->
<section class="featured">
<div class="content-wrapper">
<hgroup class="title">
<h1>@ViewBag.Title.</h1>
<h2>@ViewBag.Message</h2>
</hgroup>
<p>...</p>
</div>
</section>
}

http://stackoverflow.com/a/13864352/446681
Comments: Yeurch, Thanks for replying on this. I will reactivate 933.

Edited Issue: Razor V2 Bug:Url Resolution Fails if you have Html Comment with Quotation or Apostrophe [933]

$
0
0
During discussing a thread in ASP.NET MVC forums, found a bug in Razor V2 in which the auto url resolution(~) will not work if you have an html comment with quotation or apostrophe before the url resolution(~) tag. Here is an quick example,
``` Html
<!-- '" -->
<img src="~/images/submit.png" />
```

See this thread,
[http://forums.asp.net/t/1892597.aspx/1?Using+UrlHelper+Content](http://forums.asp.net/t/1892597.aspx/1?Using+UrlHelper+Content)

Commented Issue: Razor V2 Bug:Url Resolution Fails if you have Html Comment with Quotation or Apostrophe [933]

$
0
0
During discussing a thread in ASP.NET MVC forums, found a bug in Razor V2 in which the auto url resolution(~) will not work if you have an html comment with quotation or apostrophe before the url resolution(~) tag. Here is an quick example,
``` Html
<!-- '" -->
<img src="~/images/submit.png" />
```

See this thread,
[http://forums.asp.net/t/1892597.aspx/1?Using+UrlHelper+Content](http://forums.asp.net/t/1892597.aspx/1?Using+UrlHelper+Content)
Comments: As noted on bug 710, the fix for 710 only addresses the compilation error, but the ~/ style paths are not respected

Created Unassigned: PushStreamContent not working under Self hosting server [1169]

$
0
0
The code below it is supposed to write into the console the value of the current datetime every one second. It doesn't. But if the controller is hosted under IIS (instead of under SHS), it works fine.

Test code (console app):
```
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace Client {
using System.Web.Http;
using System.Web.Http.SelfHost;

class Program {
static readonly Uri _address = new Uri("http://localhost/ddsrpc/PushContent");

static void RunClient() {
HttpSelfHostServer httpServer = new HttpSelfHostServer(new HttpSelfHostConfiguration("http://localhost"));
httpServer.Configuration.Routes.MapHttpRoute("SseTransport", "ddsrpc/{controller}");
httpServer.OpenAsync().Wait();

HttpClient client = new HttpClient();

HttpRequestMessage request = new HttpRequestMessage {
Method = HttpMethod.Get,
RequestUri = _address,
};

client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead).ContinueWith(
getTask => {
if (getTask.IsCanceled) {
return;
}
if (getTask.IsFaulted) {
throw getTask.Exception;
}
HttpResponseMessage response = getTask.Result;

response.Content.ReadAsStreamAsync().ContinueWith(
(streamTask) => {
if (streamTask.IsCanceled) {
return;
}
if (streamTask.IsFaulted) {
throw streamTask.Exception;
}

byte[] readBuffer = new byte[512];
ReadResponseStream(streamTask.Result, readBuffer);
});
});
}

private static void ReadResponseStream(Stream rspStream, byte[] readBuffer) {
Task.Factory.FromAsync<byte[], int, int, int>(rspStream.BeginRead, rspStream.EndRead, readBuffer, 0, readBuffer.Length, state: null).ContinueWith(
(readTask) => {
if (readTask.IsCanceled) {
return;
}
if (readTask.IsFaulted) {
throw readTask.Exception;
}

int bytesRead = readTask.Result;
string content = Encoding.UTF8.GetString(readBuffer, 0, bytesRead);
Console.WriteLine("Received: {0}", content);

if (bytesRead != 0) {
ReadResponseStream(rspStream, readBuffer);
}
});
}

static void Main(string[] args) {
RunClient();

Console.WriteLine("Hit ENTER to exit...");
Console.ReadLine();
}
}

public class PushContentController : ApiController {
private static readonly Lazy<Timer> _timer = new Lazy<Timer>(() => new Timer(TimerCallback, null, 0, 1000));
private static readonly ConcurrentDictionary<StreamWriter, StreamWriter> _outputs = new ConcurrentDictionary<StreamWriter, StreamWriter>();

[HttpGet]
public HttpResponseMessage GetUpdates(HttpRequestMessage request) {
Timer t = _timer.Value;
request.Headers.AcceptEncoding.Clear();
HttpResponseMessage response = request.CreateResponse();
response.Content = new PushStreamContent(OnStreamAvailable, "text/plain");
return response;
}

private static void OnStreamAvailable(Stream stream, HttpContent headers, TransportContext context) {
StreamWriter sWriter = new StreamWriter(stream);
_outputs.TryAdd(sWriter, sWriter);
}

private static void TimerCallback(object state) {
foreach (var kvp in _outputs.ToArray()) {
try {
kvp.Value.Write(DateTime.Now);
kvp.Value.Flush();
} catch {
StreamWriter sWriter;
_outputs.TryRemove(kvp.Value, out sWriter);
}
}
}
}
}
```

Edited Feature: We should open up the configuration.Services to allow user register their custom services [873]

$
0
0
Today if one tries to add a custom service to the configuration.Services bag, it will throw exception saying that it does not support unknown services.

We should open this up so that people don't have to use configuration.Property bag to store those config wide settings. Also, because we will use DI first, custom service type will get the benefit.

Closed Issue: Razor V2 Bug:Url Resolution Fails if you have Html Comment with Quotation or Apostrophe [933]

$
0
0
During discussing a thread in ASP.NET MVC forums, found a bug in Razor V2 in which the auto url resolution(~) will not work if you have an html comment with quotation or apostrophe before the url resolution(~) tag. Here is an quick example,
``` Html
<!-- '" -->
<img src="~/images/submit.png" />
```

See this thread,
[http://forums.asp.net/t/1892597.aspx/1?Using+UrlHelper+Content](http://forums.asp.net/t/1892597.aspx/1?Using+UrlHelper+Content)
Comments: I verified with MVC5 (0723 build) with Dev12.
Viewing all 7215 articles
Browse latest View live


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