diff --git a/src/Microsoft.AspNet.Mvc.Core/CreatedAtActionResult.cs b/src/Microsoft.AspNet.Mvc.Core/CreatedAtActionResult.cs
index 2e1c5c7aba..709d6b2558 100644
--- a/src/Microsoft.AspNet.Mvc.Core/CreatedAtActionResult.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/CreatedAtActionResult.cs
@@ -7,6 +7,7 @@
using Microsoft.AspNet.Mvc.Core;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Internal;
+using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNet.Mvc
{
@@ -73,7 +74,7 @@ protected override void OnFormatting([NotNull] ActionContext context)
throw new InvalidOperationException(Resources.NoRoutesMatched);
}
- context.HttpContext.Response.Headers.Set("Location", url);
+ context.HttpContext.Response.Headers[HeaderNames.Location] = url;
}
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.Core/CreatedAtRouteResult.cs b/src/Microsoft.AspNet.Mvc.Core/CreatedAtRouteResult.cs
index 1767fed7bf..5131136bf1 100644
--- a/src/Microsoft.AspNet.Mvc.Core/CreatedAtRouteResult.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/CreatedAtRouteResult.cs
@@ -7,6 +7,7 @@
using Microsoft.AspNet.Mvc.Core;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Internal;
+using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNet.Mvc
{
@@ -70,7 +71,7 @@ protected override void OnFormatting([NotNull] ActionContext context)
throw new InvalidOperationException(Resources.NoRoutesMatched);
}
- context.HttpContext.Response.Headers.Set("Location", url);
+ context.HttpContext.Response.Headers[HeaderNames.Location] = url;
}
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.Core/CreatedResult.cs b/src/Microsoft.AspNet.Mvc.Core/CreatedResult.cs
index 31801556ed..af7148657f 100644
--- a/src/Microsoft.AspNet.Mvc.Core/CreatedResult.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/CreatedResult.cs
@@ -4,6 +4,7 @@
using System;
using Microsoft.AspNet.Http;
using Microsoft.Framework.Internal;
+using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNet.Mvc
{
@@ -50,7 +51,7 @@ public string Location
///
protected override void OnFormatting([NotNull] ActionContext context)
{
- context.HttpContext.Response.Headers.Set("Location", Location);
+ context.HttpContext.Response.Headers[HeaderNames.Location] = Location;
}
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.Core/FileResult.cs b/src/Microsoft.AspNet.Mvc.Core/FileResult.cs
index 814be3e544..d33ce318c4 100644
--- a/src/Microsoft.AspNet.Mvc.Core/FileResult.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/FileResult.cs
@@ -68,7 +68,7 @@ public override Task ExecuteResultAsync([NotNull] ActionContext context)
// basis for the actual filename, where possible.
var cd = new ContentDispositionHeaderValue("attachment");
cd.SetHttpFileName(FileDownloadName);
- context.HttpContext.Response.Headers.Set(HeaderNames.ContentDisposition, cd.ToString());
+ context.HttpContext.Response.Headers[HeaderNames.ContentDisposition] = cd.ToString();
}
// We aren't flowing the cancellation token appropriately, see
diff --git a/src/Microsoft.AspNet.Mvc.Core/HttpMethodConstraint.cs b/src/Microsoft.AspNet.Mvc.Core/HttpMethodConstraint.cs
index edabe282c8..be65914c9a 100644
--- a/src/Microsoft.AspNet.Mvc.Core/HttpMethodConstraint.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/HttpMethodConstraint.cs
@@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
+using Microsoft.AspNet.Primitives;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc
@@ -62,12 +63,12 @@ public bool Accept([NotNull] ActionConstraintContext context)
if (request.Headers.ContainsKey(OriginHeader))
{
// Update the http method if it is preflight request.
- var accessControlRequestMethod = request.Headers.Get(AccessControlRequestMethod);
+ var accessControlRequestMethod = request.Headers[AccessControlRequestMethod];
if (string.Equals(
request.Method,
PreflightHttpMethod,
StringComparison.Ordinal) &&
- accessControlRequestMethod != null)
+ !StringValues.IsNullOrEmpty(accessControlRequestMethod))
{
method = accessControlRequestMethod;
}
diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/FormCollectionModelBinder.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/FormCollectionModelBinder.cs
index de3cbf4061..431cd1329b 100644
--- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/FormCollectionModelBinder.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/FormCollectionModelBinder.cs
@@ -7,6 +7,7 @@
using System.Threading.Tasks;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Internal;
+using Microsoft.AspNet.Primitives;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.ModelBinding
@@ -42,7 +43,7 @@ public async Task BindModelAsync([NotNull] ModelBindingConte
}
else
{
- model = new FormCollection(new Dictionary());
+ model = new FormCollection(new Dictionary());
}
var validationNode =
diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/HeaderModelBinder.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/HeaderModelBinder.cs
index 2a253ece64..9061ad5848 100644
--- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/HeaderModelBinder.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/HeaderModelBinder.cs
@@ -7,6 +7,7 @@
using System.Reflection;
#endif
using System.Threading.Tasks;
+using Microsoft.AspNet.Primitives;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.ModelBinding
@@ -36,7 +37,7 @@ protected override Task BindModelCoreAsync([NotNull] ModelBi
object model = null;
if (bindingContext.ModelType == typeof(string))
{
- var value = request.Headers.Get(headerName);
+ string value = request.Headers[headerName];
if (value != null)
{
model = value;
@@ -45,7 +46,7 @@ protected override Task BindModelCoreAsync([NotNull] ModelBi
else if (typeof(IEnumerable).IsAssignableFrom(bindingContext.ModelType))
{
var values = request.Headers.GetCommaSeparatedValues(headerName);
- if (values != null)
+ if (values.Count > 0)
{
model = ModelBindingHelper.ConvertValuesToCollectionType(
bindingContext.ModelType,
@@ -61,7 +62,7 @@ protected override Task BindModelCoreAsync([NotNull] ModelBi
bindingContext.ModelMetadata,
model);
- var attemptedValue = (model as string) ?? request.Headers.Get(headerName);
+ var attemptedValue = (model as string) ?? request.Headers[headerName];
var valueProviderResult = new ValueProviderResult(model, attemptedValue, CultureInfo.InvariantCulture);
bindingContext.ModelState.SetModelValue(bindingContext.ModelName, valueProviderResult);
}
diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProvider.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProvider.cs
index e1e319dd95..6ea03df260 100644
--- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProvider.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProvider.cs
@@ -6,6 +6,7 @@
using System.Diagnostics;
using System.Globalization;
using System.Threading.Tasks;
+using Microsoft.AspNet.Primitives;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.ModelBinding
@@ -16,10 +17,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
///
public class JQueryFormValueProvider : BindingSourceValueProvider, IEnumerableValueProvider
{
- private readonly Func>> _valuesFactory;
+ private readonly Func>> _valuesFactory;
private PrefixContainer _prefixContainer;
- private IDictionary _values;
+ private IDictionary _values;
///
/// Initializes a new instance of the class.
@@ -29,7 +30,7 @@ public class JQueryFormValueProvider : BindingSourceValueProvider, IEnumerableVa
/// The culture to return with ValueProviderResult instances.
public JQueryFormValueProvider(
[NotNull] BindingSource bindingSource,
- [NotNull] Func>> valuesFactory,
+ [NotNull] Func>> valuesFactory,
CultureInfo culture)
: base(bindingSource)
{
@@ -40,7 +41,7 @@ public JQueryFormValueProvider(
// Internal for testing.
internal JQueryFormValueProvider(
[NotNull] BindingSource bindingSource,
- [NotNull] IDictionary values,
+ [NotNull] IDictionary values,
CultureInfo culture)
: base(bindingSource)
{
@@ -70,22 +71,26 @@ public override async Task GetValueAsync(string key)
{
var dictionary = await GetDictionary();
- string[] values;
- if (dictionary.TryGetValue(key, out values) && values != null && values.Length > 0)
+ StringValues values;
+ if (dictionary.TryGetValue(key, out values) && values.Count > 0)
{
- // Success.
- if (values.Length == 1)
+ if (values.Count == 1)
{
- return new ValueProviderResult(values[0], values[0], Culture);
+ var value = (string)values;
+ return new ValueProviderResult(value, value, Culture);
+ }
+ else
+ {
+ var rawValue = (string[])values;
+ var value = (string)values;
+ return new ValueProviderResult(rawValue, value, Culture);
}
-
- return new ValueProviderResult(values, string.Join(",", values), Culture);
}
return null;
}
- private async Task> GetDictionary()
+ private async Task> GetDictionary()
{
if (_values == null)
{
diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProviderFactory.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProviderFactory.cs
index e40cd205c0..3b7052a636 100644
--- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProviderFactory.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/JQueryFormValueProviderFactory.cs
@@ -8,6 +8,7 @@
using System.Threading.Tasks;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc.Core;
+using Microsoft.AspNet.Primitives;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.ModelBinding
@@ -29,11 +30,11 @@ public IValueProvider GetValueProvider([NotNull] ValueProviderFactoryContext con
return null;
}
- private static async Task> GetValueCollectionAsync(HttpRequest request)
+ private static async Task> GetValueCollectionAsync(HttpRequest request)
{
var formCollection = await request.ReadFormAsync();
- var dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase);
+ var dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase);
foreach (var entry in formCollection)
{
var key = NormalizeJQueryToMvc(entry.Key);
diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/ReadableStringCollectionValueProvider.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/ReadableStringCollectionValueProvider.cs
index 346617eea9..32a23dc639 100644
--- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/ReadableStringCollectionValueProvider.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/ReadableStringCollectionValueProvider.cs
@@ -7,6 +7,7 @@
using System.Globalization;
using System.Threading.Tasks;
using Microsoft.AspNet.Http;
+using Microsoft.AspNet.Primitives;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc.ModelBinding
@@ -80,21 +81,21 @@ public virtual async Task> GetKeysFromPrefixAsync([N
public override async Task GetValueAsync([NotNull] string key)
{
var collection = await GetValueCollectionAsync();
- var values = collection.GetValues(key);
+ var values = collection[key];
ValueProviderResult result;
- if (values == null)
+ if (values.Count == 0)
{
result = null;
}
else if (values.Count == 1)
{
- var value = (string)values[0];
+ var value = (string)values;
result = new ValueProviderResult(value, value, _culture);
}
else
{
- result = new ValueProviderResult(values, _values.Get(key), _culture);
+ result = new ValueProviderResult((string[])values, _values[key], _culture);
}
return result;
diff --git a/src/Microsoft.AspNet.Mvc.Core/ResponseCacheFilter.cs b/src/Microsoft.AspNet.Mvc.Core/ResponseCacheFilter.cs
index ebe249a72b..988b820c39 100644
--- a/src/Microsoft.AspNet.Mvc.Core/ResponseCacheFilter.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/ResponseCacheFilter.cs
@@ -6,6 +6,7 @@
using System.Linq;
using Microsoft.AspNet.Mvc.Core;
using Microsoft.Framework.Internal;
+using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNet.Mvc
{
@@ -94,24 +95,24 @@ public void OnActionExecuting([NotNull] ActionExecutingContext context)
var headers = context.HttpContext.Response.Headers;
// Clear all headers
- headers.Remove("Vary");
- headers.Remove("Cache-control");
- headers.Remove("Pragma");
+ headers.Remove(HeaderNames.Vary);
+ headers.Remove(HeaderNames.CacheControl);
+ headers.Remove(HeaderNames.Pragma);
if (!string.IsNullOrEmpty(VaryByHeader))
{
- headers.Set("Vary", VaryByHeader);
+ headers[HeaderNames.Vary] = VaryByHeader;
}
if (NoStore)
{
- headers.Set("Cache-control", "no-store");
+ headers[HeaderNames.CacheControl] = "no-store";
// Cache-control: no-store, no-cache is valid.
if (Location == ResponseCacheLocation.None)
{
- headers.Append("Cache-control", "no-cache");
- headers.Set("Pragma", "no-cache");
+ headers.AppendCommaSeparatedValues(HeaderNames.CacheControl, "no-cache");
+ headers[HeaderNames.Pragma] = "no-cache";
}
}
else
@@ -127,7 +128,7 @@ public void OnActionExecuting([NotNull] ActionExecutingContext context)
break;
case ResponseCacheLocation.None:
cacheControlValue = "no-cache";
- headers.Set("Pragma", "no-cache");
+ headers[HeaderNames.Pragma] = "no-cache";
break;
}
@@ -140,7 +141,7 @@ public void OnActionExecuting([NotNull] ActionExecutingContext context)
if (cacheControlValue != null)
{
- headers.Set("Cache-control", cacheControlValue);
+ headers[HeaderNames.CacheControl] = cacheControlValue;
}
}
}
diff --git a/src/Microsoft.AspNet.Mvc.Cors/CorsAuthorizationFilter.cs b/src/Microsoft.AspNet.Mvc.Cors/CorsAuthorizationFilter.cs
index bc07ef6373..e12b6268fb 100644
--- a/src/Microsoft.AspNet.Mvc.Cors/CorsAuthorizationFilter.cs
+++ b/src/Microsoft.AspNet.Mvc.Cors/CorsAuthorizationFilter.cs
@@ -7,6 +7,7 @@
using System.Threading.Tasks;
using Microsoft.AspNet.Cors.Core;
using Microsoft.AspNet.Http;
+using Microsoft.AspNet.Primitives;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc
@@ -63,12 +64,12 @@ public async Task OnAuthorizationAsync([NotNull] AuthorizationContext context)
_corsService.ApplyResult(result, context.HttpContext.Response);
var accessControlRequestMethod =
- httpContext.Request.Headers.Get(CorsConstants.AccessControlRequestMethod);
+ httpContext.Request.Headers[CorsConstants.AccessControlRequestMethod];
if (string.Equals(
request.Method,
CorsConstants.PreflightHttpMethod,
StringComparison.Ordinal) &&
- accessControlRequestMethod != null)
+ !StringValues.IsNullOrEmpty(accessControlRequestMethod))
{
// If this was a preflight, there is no need to run anything else.
// Also the response is always 200 so that anyone after mvc can handle the pre flight request.
diff --git a/src/Microsoft.AspNet.Mvc.Cors/DisableCorsAuthorizationFilter.cs b/src/Microsoft.AspNet.Mvc.Cors/DisableCorsAuthorizationFilter.cs
index 4885d622f5..2ec9d48f3c 100644
--- a/src/Microsoft.AspNet.Mvc.Cors/DisableCorsAuthorizationFilter.cs
+++ b/src/Microsoft.AspNet.Mvc.Cors/DisableCorsAuthorizationFilter.cs
@@ -5,6 +5,7 @@
using System.Threading.Tasks;
using Microsoft.AspNet.Cors.Core;
using Microsoft.AspNet.Http;
+using Microsoft.AspNet.Primitives;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Mvc
@@ -27,12 +28,12 @@ public int Order
public Task OnAuthorizationAsync([NotNull] AuthorizationContext context)
{
var accessControlRequestMethod =
- context.HttpContext.Request.Headers.Get(CorsConstants.AccessControlRequestMethod);
+ context.HttpContext.Request.Headers[CorsConstants.AccessControlRequestMethod];
if (string.Equals(
context.HttpContext.Request.Method,
CorsConstants.PreflightHttpMethod,
StringComparison.Ordinal) &&
- accessControlRequestMethod != null)
+ !StringValues.IsNullOrEmpty(accessControlRequestMethod))
{
// Short circuit if the request is preflight as that should not result in action execution.
context.Result = new HttpStatusCodeResult(StatusCodes.Status200OK);
diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/Formatters/HttpResponseMessageOutputFormatter.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/Formatters/HttpResponseMessageOutputFormatter.cs
index ce6f977a51..e09fa19669 100644
--- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/Formatters/HttpResponseMessageOutputFormatter.cs
+++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/Formatters/HttpResponseMessageOutputFormatter.cs
@@ -53,7 +53,7 @@ public async Task WriteAsync(OutputFormatterContext context)
foreach (var header in responseHeaders)
{
- response.Headers.AppendValues(header.Key, header.Value.ToArray());
+ response.Headers.Append(header.Key, header.Value.ToArray());
}
if (responseMessage.Content != null)
@@ -67,7 +67,7 @@ public async Task WriteAsync(OutputFormatterContext context)
foreach (var header in contentHeaders)
{
- response.Headers.AppendValues(header.Key, header.Value.ToArray());
+ response.Headers.Append(header.Key, header.Value.ToArray());
}
await responseMessage.Content.CopyToAsync(response.Body);
diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageFeature.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageFeature.cs
index a0c2ae056b..0af8ba7221 100644
--- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageFeature.cs
+++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageFeature.cs
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using Microsoft.AspNet.Http;
@@ -58,9 +59,9 @@ private static HttpRequestMessage CreateHttpRequestMessage(HttpContext httpConte
{
// Every header should be able to fit into one of the two header collections.
// Try message.Headers first since that accepts more of them.
- if (!message.Headers.TryAddWithoutValidation(header.Key, header.Value))
+ if (!message.Headers.TryAddWithoutValidation(header.Key, (IEnumerable)header.Value))
{
- var added = message.Content.Headers.TryAddWithoutValidation(header.Key, header.Value);
+ var added = message.Content.Headers.TryAddWithoutValidation(header.Key, (IEnumerable)header.Value);
Debug.Assert(added);
}
}
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/CreatedAtActionResultTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/CreatedAtActionResultTests.cs
index 5d2da109ac..4c3736a536 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/CreatedAtActionResultTests.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/CreatedAtActionResultTests.cs
@@ -70,7 +70,7 @@ private static HttpResponse GetMockedHttpResponseObject()
var httpResponse = new Mock();
httpResponse.SetupProperty(o => o.StatusCode);
httpResponse.Setup(o => o.Headers).Returns(
- new HeaderDictionary(new Dictionary()));
+ new HeaderDictionary());
httpResponse.SetupGet(o => o.Body).Returns(stream);
return httpResponse.Object;
}
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/CreatedResultTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/CreatedResultTests.cs
index 7b556a8838..49d31674eb 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/CreatedResultTests.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/CreatedResultTests.cs
@@ -53,7 +53,7 @@ public async Task CreatedResult_OverwritesLocationHeader()
var location = "/test/";
var httpContext = GetHttpContext();
var actionContext = GetActionContext(httpContext);
- httpContext.Response.Headers.Set("Location", "/different/location/");
+ httpContext.Response.Headers["Location"] = "/different/location/";
var result = new CreatedResult(location, "testInput");
// Act
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/FormatFilterTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/FormatFilterTest.cs
index 5f855d6c3a..0ade1df1b3 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/FormatFilterTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/FormatFilterTest.cs
@@ -72,7 +72,7 @@ public void FormatFilter_ContextContainsFormat_InRouteAndQueryData()
// Query contains xml
httpContext.Setup(c => c.Request.Query.ContainsKey("format")).Returns(true);
- httpContext.Setup(c => c.Request.Query.Get("format")).Returns("xml");
+ httpContext.Setup(c => c.Request.Query["format"]).Returns("xml");
// Routedata contains json
var data = new RouteData();
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CompositeValueProviderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CompositeValueProviderTest.cs
index 6537336403..40a1f7fa87 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CompositeValueProviderTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CompositeValueProviderTest.cs
@@ -8,6 +8,7 @@
using System.Globalization;
#if DNX451
using System.Threading.Tasks;
+using Microsoft.AspNet.Primitives;
using Moq;
using Xunit;
#endif
@@ -18,11 +19,11 @@ public class CompositeValueProviderTest : EnumerableValueProviderTest
{
protected override IEnumerableValueProvider GetEnumerableValueProvider(
BindingSource bindingSource,
- IDictionary values,
+ IDictionary values,
CultureInfo culture)
{
var emptyValueProvider =
- new JQueryFormValueProvider(bindingSource, new Dictionary(), culture);
+ new JQueryFormValueProvider(bindingSource, new Dictionary(), culture);
var valueProvider = new JQueryFormValueProvider(bindingSource, values, culture);
return new CompositeValueProvider(new[] { emptyValueProvider, valueProvider });
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/DictionaryModelBinderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/DictionaryModelBinderTest.cs
index 617bd67337..9ebc8c58fc 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/DictionaryModelBinderTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/DictionaryModelBinderTest.cs
@@ -8,6 +8,7 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Http.Internal;
+using Microsoft.AspNet.Primitives;
using Moq;
using Xunit;
@@ -442,10 +443,10 @@ private static IValueProvider CreateEnumerableValueProvider(
string keyFormat,
IDictionary dictionary)
{
- // Convert to an IDictionary then wrap it up.
+ // Convert to an IDictionary then wrap it up.
var backingStore = dictionary.ToDictionary(
kvp => string.Format(keyFormat, kvp.Key),
- kvp => new[] { kvp.Value });
+ kvp => (StringValues)kvp.Value);
var stringCollection = new ReadableStringCollection(backingStore);
return new ReadableStringCollectionValueProvider(
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/EnumerableValueProviderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/EnumerableValueProviderTest.cs
index 9fdaf664f6..d816c9f39f 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/EnumerableValueProviderTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/EnumerableValueProviderTest.cs
@@ -5,34 +5,35 @@
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
+using Microsoft.AspNet.Primitives;
using Xunit;
namespace Microsoft.AspNet.Mvc.ModelBinding
{
public abstract class EnumerableValueProviderTest
{
- private static readonly IDictionary _backingStore = new Dictionary
+ private static readonly IDictionary _backingStore = new Dictionary
{
{ "some", new[] { "someValue1", "someValue2" } },
- { "null_value", null },
+ { "null_value", StringValues.Empty },
{ "prefix.name", new[] { "someOtherValue" } },
- { "prefix.null_value", null },
- { "prefix.property1.property", null },
- { "prefix.property2[index]", null },
- { "prefix[index1]", null },
- { "prefix[index1].property1", null },
- { "prefix[index1].property2", null },
- { "prefix[index2].property", null },
- { "[index]", null },
- { "[index].property", null },
- { "[index][anotherIndex]", null },
+ { "prefix.null_value", StringValues.Empty },
+ { "prefix.property1.property", StringValues.Empty },
+ { "prefix.property2[index]", StringValues.Empty },
+ { "prefix[index1]", StringValues.Empty },
+ { "prefix[index1].property1", StringValues.Empty },
+ { "prefix[index1].property2", StringValues.Empty },
+ { "prefix[index2].property", StringValues.Empty },
+ { "[index]", StringValues.Empty },
+ { "[index].property", StringValues.Empty },
+ { "[index][anotherIndex]", StringValues.Empty },
};
[Fact]
public async Task ContainsPrefixAsync_WithEmptyCollection_ReturnsFalseForEmptyPrefix()
{
// Arrange
- var backingStore = new Dictionary();
+ var backingStore = new Dictionary();
var valueProvider = GetEnumerableValueProvider(BindingSource.Query, backingStore, culture: null);
// Act
@@ -184,7 +185,7 @@ public async Task GetValueAsync_MultiValue()
// Assert
Assert.NotNull(result);
- Assert.Equal(new[] { "someValue1", "someValue2" }, (IList)result.RawValue);
+ Assert.Equal(new[] { "someValue1", "someValue2" }, result.RawValue);
Assert.Equal("someValue1,someValue2", result.AttemptedValue);
Assert.Equal(culture, result.Culture);
}
@@ -209,7 +210,7 @@ public async Task GetValue_NullValue(string key)
public async Task GetValueAsync_NullMultipleValue()
{
// Arrange
- var backingStore = new Dictionary
+ var backingStore = new Dictionary
{
{ "key", new string[] { null, null, "value" } },
};
@@ -278,7 +279,7 @@ public void FilterExclude()
private IBindingSourceValueProvider GetBindingSourceValueProvider(
BindingSource bindingSource,
- IDictionary values,
+ IDictionary values,
CultureInfo culture)
{
var provider = GetEnumerableValueProvider(bindingSource, values, culture) as IBindingSourceValueProvider;
@@ -291,7 +292,7 @@ private IBindingSourceValueProvider GetBindingSourceValueProvider(
protected abstract IEnumerableValueProvider GetEnumerableValueProvider(
BindingSource bindingSource,
- IDictionary values,
+ IDictionary values,
CultureInfo culture);
}
}
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormCollectionModelBinderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormCollectionModelBinderTest.cs
index 9e6216a9e1..124e5d2dc9 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormCollectionModelBinderTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormCollectionModelBinderTest.cs
@@ -9,6 +9,7 @@
using System.Threading.Tasks;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Internal;
+using Microsoft.AspNet.Primitives;
using Moq;
using Xunit;
@@ -20,10 +21,10 @@ public class FormCollectionModelBinderTest
public async Task FormCollectionModelBinder_ValidType_BindSuccessful()
{
// Arrange
- var formCollection = new FormCollection(new Dictionary
+ var formCollection = new FormCollection(new Dictionary
{
- { "field1", new string[] { "value1" } },
- { "field2", new string[] { "value2" } }
+ { "field1", "value1" },
+ { "field2", "value2" }
});
var httpContext = GetMockHttpContext(formCollection);
var bindingContext = GetBindingContext(typeof(FormCollection), httpContext);
@@ -48,10 +49,10 @@ public async Task FormCollectionModelBinder_ValidType_BindSuccessful()
public async Task FormCollectionModelBinder_InvalidType_BindFails()
{
// Arrange
- var formCollection = new FormCollection(new Dictionary
+ var formCollection = new FormCollection(new Dictionary
{
- { "field1", new string[] { "value1" } },
- { "field2", new string[] { "value2" } }
+ { "field1", "value1" },
+ { "field2", "value2" }
});
var httpContext = GetMockHttpContext(formCollection);
var bindingContext = GetBindingContext(typeof(string), httpContext);
@@ -85,10 +86,10 @@ public async Task FormCollectionModelBinder_NoForm_BindSuccessful_ReturnsEmptyFo
public async Task FormCollectionModelBinder_CustomFormCollection_BindSuccessful()
{
// Arrange
- var formCollection = new MyFormCollection(new Dictionary
+ var formCollection = new MyFormCollection(new Dictionary
{
- { "field1", new string[] { "value1" } },
- { "field2", new string[] { "value2" } }
+ { "field1", "value1" },
+ { "field2", "value2" }
});
var httpContext = GetMockHttpContext(formCollection);
var bindingContext = GetBindingContext(typeof(FormCollection), httpContext);
@@ -134,11 +135,11 @@ private static ModelBindingContext GetBindingContext(Type modelType, HttpContext
private class MyFormCollection : ReadableStringCollection, IFormCollection
{
- public MyFormCollection(IDictionary store) : this(store, new FormFileCollection())
+ public MyFormCollection(IDictionary store) : this(store, new FormFileCollection())
{
}
- public MyFormCollection(IDictionary store, IFormFileCollection files) : base(store)
+ public MyFormCollection(IDictionary store, IFormFileCollection files) : base(store)
{
Files = files;
}
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderFactoryTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderFactoryTest.cs
index c95b2691d5..179f1bf956 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderFactoryTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderFactoryTest.cs
@@ -6,13 +6,14 @@
using System.Globalization;
using System.Threading.Tasks;
using Microsoft.AspNet.Http.Internal;
+using Microsoft.AspNet.Primitives;
using Xunit;
namespace Microsoft.AspNet.Mvc.ModelBinding.Test
{
public class JQueryFormValueProviderFactoryTest
{
- private static readonly IDictionary _backingStore = new Dictionary
+ private static readonly IDictionary _backingStore = new Dictionary
{
{ "[]", new[] { "found" } },
{ "[]property1", new[] { "found" } },
@@ -118,7 +119,7 @@ public async Task GetValueProvider_ReturnsValueProvider_ContainingExpectedKeys(s
private static ValueProviderFactoryContext CreateContext(
string contentType,
- IDictionary formValues)
+ IDictionary formValues)
{
var context = new DefaultHttpContext();
context.Request.ContentType = contentType;
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderTest.cs
index 4fa1b91d66..1d2aef6e3f 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/JQueryFormValueProviderTest.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Globalization;
+using Microsoft.AspNet.Primitives;
namespace Microsoft.AspNet.Mvc.ModelBinding
{
@@ -10,7 +11,7 @@ public class JQueryFormValueProviderTest : EnumerableValueProviderTest
{
protected override IEnumerableValueProvider GetEnumerableValueProvider(
BindingSource bindingSource,
- IDictionary values,
+ IDictionary values,
CultureInfo culture)
{
return new JQueryFormValueProvider(bindingSource, values, culture);
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ReadableStringCollectionValueProviderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ReadableStringCollectionValueProviderTest.cs
index 9a3cd94490..7785496d70 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ReadableStringCollectionValueProviderTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ReadableStringCollectionValueProviderTest.cs
@@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Globalization;
using Microsoft.AspNet.Http.Internal;
+using Microsoft.AspNet.Primitives;
namespace Microsoft.AspNet.Mvc.ModelBinding
{
@@ -11,7 +12,7 @@ public class ReadableStringCollectionValueProviderTest : EnumerableValueProvider
{
protected override IEnumerableValueProvider GetEnumerableValueProvider(
BindingSource bindingSource,
- IDictionary values,
+ IDictionary values,
CultureInfo culture)
{
var backingStore = new ReadableStringCollection(values);
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ResponseCacheFilterTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ResponseCacheFilterTest.cs
index 347ada991b..6e758e98a4 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/ResponseCacheFilterTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/ResponseCacheFilterTest.cs
@@ -27,7 +27,7 @@ public void ResponseCacheFilter_DoesNotThrow_WhenNoStoreIsTrue()
cache.OnActionExecuting(context);
// Assert
- Assert.Equal("no-store", context.HttpContext.Response.Headers.Get("Cache-control"));
+ Assert.Equal("no-store", context.HttpContext.Response.Headers["Cache-control"]);
}
[Fact]
@@ -157,7 +157,7 @@ public void OnActionExecuting_CanSetCacheControlHeaders(ResponseCacheFilter cach
cache.OnActionExecuting(context);
// Assert
- Assert.Equal(output, context.HttpContext.Response.Headers.Get("Cache-control"));
+ Assert.Equal(output, context.HttpContext.Response.Headers["Cache-control"]);
}
public static IEnumerable