diff --git a/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/ConsumesAttribute.cs b/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/ConsumesAttribute.cs index 6b61e23d38..b118a51cc3 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/ConsumesAttribute.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ActionConstraints/ConsumesAttribute.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Microsoft.AspNet.Mvc.Core; using Microsoft.Net.Http.Headers; namespace Microsoft.AspNet.Mvc @@ -146,11 +147,19 @@ namespace Microsoft.AspNet.Mvc private List GetContentTypes(string firstArg, string[] args) { + var completeArgs = new List(); + completeArgs.Add(firstArg); + completeArgs.AddRange(args); var contentTypes = new List(); - contentTypes.Add(MediaTypeHeaderValue.Parse(firstArg)); - foreach (var item in args) + foreach (var arg in completeArgs) { - var contentType = MediaTypeHeaderValue.Parse(item); + var contentType = MediaTypeHeaderValue.Parse(arg); + if (contentType.MatchesAllSubTypes || contentType.MatchesAllTypes) + { + throw new InvalidOperationException( + Resources.FormatMatchAllContentTypeIsNotAllowed(arg)); + } + contentTypes.Add(contentType); } diff --git a/src/Microsoft.AspNet.Mvc.Core/ActionResults/ObjectResult.cs b/src/Microsoft.AspNet.Mvc.Core/ActionResults/ObjectResult.cs index 0344300968..3eb0cf431f 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ActionResults/ObjectResult.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ActionResults/ObjectResult.cs @@ -2,10 +2,12 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNet.Http; +using Microsoft.AspNet.Mvc.Core; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.OptionsModel; using Microsoft.Net.Http.Headers; @@ -36,6 +38,8 @@ namespace Microsoft.AspNet.Mvc public override async Task ExecuteResultAsync(ActionContext context) { + // See if the list of content types added to this object result is valid. + ThrowIfUnsupportedContentType(); var formatters = GetDefaultFormatters(context); var formatterContext = new OutputFormatterContext() { @@ -218,6 +222,17 @@ namespace Microsoft.AspNet.Mvc return selectedFormatter; } + private void ThrowIfUnsupportedContentType() + { + var matchAllContentType = ContentTypes?.FirstOrDefault( + contentType => contentType.MatchesAllSubTypes || contentType.MatchesAllTypes); + if (matchAllContentType != null) + { + throw new InvalidOperationException( + Resources.FormatObjectResult_MatchAllContentType(matchAllContentType, nameof(ContentTypes))); + } + } + private static IEnumerable SortMediaTypeHeaderValues( IEnumerable headerValues) { diff --git a/src/Microsoft.AspNet.Mvc.Core/Filters/ProducesAttribute.cs b/src/Microsoft.AspNet.Mvc.Core/Filters/ProducesAttribute.cs index 619dd9f74f..b3ae09cd90 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Filters/ProducesAttribute.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Filters/ProducesAttribute.cs @@ -3,6 +3,8 @@ using System; using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNet.Mvc.Core; using Microsoft.AspNet.Mvc.Description; using Microsoft.Net.Http.Headers; @@ -15,7 +17,7 @@ namespace Microsoft.AspNet.Mvc [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class ProducesAttribute : ResultFilterAttribute, IApiResponseMetadataProvider { - public ProducesAttribute(string contentType, params string[] additionalContentTypes) + public ProducesAttribute([NotNull] string contentType, params string[] additionalContentTypes) { ContentTypes = GetContentTypes(contentType, additionalContentTypes); } @@ -37,11 +39,19 @@ namespace Microsoft.AspNet.Mvc private List GetContentTypes(string firstArg, string[] args) { + var completeArgs = new List(); + completeArgs.Add(firstArg); + completeArgs.AddRange(args); var contentTypes = new List(); - contentTypes.Add(MediaTypeHeaderValue.Parse(firstArg)); - foreach (var item in args) + foreach (var arg in completeArgs) { - var contentType = MediaTypeHeaderValue.Parse(item); + var contentType = MediaTypeHeaderValue.Parse(arg); + if (contentType.MatchesAllSubTypes || contentType.MatchesAllTypes) + { + throw new InvalidOperationException( + Resources.FormatMatchAllContentTypeIsNotAllowed(arg)); + } + contentTypes.Add(contentType); } diff --git a/src/Microsoft.AspNet.Mvc.Core/Properties/Resources.Designer.cs b/src/Microsoft.AspNet.Mvc.Core/Properties/Resources.Designer.cs index 2ecefcaaee..5ad74f797a 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Properties/Resources.Designer.cs @@ -10,6 +10,38 @@ namespace Microsoft.AspNet.Mvc.Core private static readonly ResourceManager _resourceManager = new ResourceManager("Microsoft.AspNet.Mvc.Core.Resources", typeof(Resources).GetTypeInfo().Assembly); + /// + /// The argument '{0}' is invalid. Media types containing wildcards (*) are not supported. + /// + internal static string MatchAllContentTypeIsNotAllowed + { + get { return GetString("MatchAllContentTypeIsNotAllowed"); } + } + + /// + /// The argument '{0}' is invalid. Media types containing wildcards (*) are not supported. + /// + internal static string FormatMatchAllContentTypeIsNotAllowed(object p0) + { + return string.Format(CultureInfo.CurrentCulture, GetString("MatchAllContentTypeIsNotAllowed"), p0); + } + + /// + /// The content-type '{0}' added in the '{1}' property is invalid. Media types containing wildcards (*) are not supported. + /// + internal static string ObjectResult_MatchAllContentType + { + get { return GetString("ObjectResult_MatchAllContentType"); } + } + + /// + /// The content-type '{0}' added in the '{1}' property is invalid. Media types containing wildcards (*) are not supported. + /// + internal static string FormatObjectResult_MatchAllContentType(object p0, object p1) + { + return string.Format(CultureInfo.CurrentCulture, GetString("ObjectResult_MatchAllContentType"), p0, p1); + } + /// /// The provided anti-forgery token failed a custom data check. /// diff --git a/src/Microsoft.AspNet.Mvc.Core/Resources.resx b/src/Microsoft.AspNet.Mvc.Core/Resources.resx index 2b17cde37e..0ce426a309 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Resources.resx +++ b/src/Microsoft.AspNet.Mvc.Core/Resources.resx @@ -117,6 +117,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + The argument '{0}' is invalid. Media types which match all types or match all subtypes are not supported. + + + The content-type '{0}' added in the '{1}' property is invalid. Media types which match all types or match all subtypes are not supported. + The provided anti-forgery token failed a custom data check. diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ActionResults/ObjectResultTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ActionResults/ObjectResultTests.cs index aec28adec5..34f9e6a359 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ActionResults/ObjectResultTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ActionResults/ObjectResultTests.cs @@ -16,6 +16,7 @@ using Microsoft.Framework.DependencyInjection.Fallback; using Microsoft.Framework.OptionsModel; using Microsoft.Net.Http.Headers; using Moq; +using Newtonsoft.Json.Utilities; using Xunit; namespace Microsoft.AspNet.Mvc.Core.Test.ActionResults @@ -616,6 +617,32 @@ namespace Microsoft.AspNet.Mvc.Core.Test.ActionResults response.VerifySet(resp => resp.ContentType = expectedResponseContentType); } + [Theory] + [InlineData("application/*", "application/*")] + [InlineData("application/xml, application/*, application/json", "application/*")] + [InlineData("application/*, application/json", "application/*")] + + [InlineData("*/*", "*/*")] + [InlineData("application/xml, */*, application/json", "*/*")] + [InlineData("*/*, application/json", "*/*")] + public async Task ObjectResult_MatchAllContentType_Throws(string content, string invalidContentType) + { + // Arrange + var contentTypes = content.Split(','); + var objectResult = new ObjectResult(new Person() { Name = "John" }); + objectResult.ContentTypes = contentTypes.Select(contentType => MediaTypeHeaderValue.Parse(contentType)) + .ToList(); + + // Act & Assert + var exception = await Assert.ThrowsAsync( + () => objectResult.ExecuteResultAsync(null)); + + var expectedMessage = string.Format("The content-type '{0}' added in the 'ContentTypes' property is " + + "invalid. Media types which match all types or match all subtypes are not supported.", + invalidContentType); + Assert.Equal(expectedMessage, exception.Message); + } + private static ActionContext CreateMockActionContext( HttpResponse response = null, string requestAcceptHeader = "application/*", diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ConsumesAttributeTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ConsumesAttributeTests.cs index be302c3542..882510a04e 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ConsumesAttributeTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ConsumesAttributeTests.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Linq; using Microsoft.AspNet.Http.Core; using Microsoft.AspNet.Routing; using Moq; @@ -26,6 +27,49 @@ namespace Microsoft.AspNet.Mvc Assert.Equal(expectedMessage, exception.Message); } + [Theory] + [InlineData("", "")] + [InlineData("application/xml,, application/json", "")] + [InlineData(", application/json", "")] + [InlineData("invalid", "invalid")] + [InlineData("application/xml,invalid, application/json", "invalid")] + [InlineData("invalid, application/json", "invalid")] + public void Constructor_UnparsableContentType_Throws(string content, string invalidContentType) + { + // Act + var contentTypes = content.Split(',').Select(contentType => contentType.Trim()).ToArray(); + + // Assert + var ex = Assert.Throws( + () => new ConsumesAttribute(contentTypes[0], contentTypes.Skip(1).ToArray())); + Assert.Equal("Invalid value '" + (invalidContentType ?? "") + "'.", + ex.Message); + } + + [Theory] + [InlineData("application/*", "application/*")] + [InlineData("application/xml, application/*, application/json", "application/*")] + [InlineData("application/*, application/json", "application/*")] + + [InlineData("*/*", "*/*")] + [InlineData("application/xml, */*, application/json", "*/*")] + [InlineData("*/*, application/json", "*/*")] + public void Constructor_InvalidContentType_Throws(string content, string invalidContentType) + { + // Act + var contentTypes = content.Split(',').Select(contentType => contentType.Trim()).ToArray(); + + // Assert + var ex = Assert.Throws( + () => new ConsumesAttribute(contentTypes[0], contentTypes.Skip(1).ToArray())); + + Assert.Equal( + string.Format("The argument '{0}' is invalid. "+ + "Media types which match all types or match all subtypes are not supported.", + invalidContentType), + ex.Message); + } + [Theory] [InlineData("application/json")] [InlineData("application/json;Parameter1=12")] diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Filters/ProducesAttributeTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Filters/ProducesAttributeTests.cs index 3e723bb0d8..718648b2f6 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Filters/ProducesAttributeTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Filters/ProducesAttributeTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Linq; using System.Threading.Tasks; using Microsoft.AspNet.Http.Core; using Microsoft.AspNet.Routing; @@ -13,7 +14,7 @@ namespace Microsoft.AspNet.Mvc.Test public class ProducesAttributeTests { [Fact] - public async Task ProducesContentAttribute_SetsContentType() + public async Task ProducesAttribute_SetsContentType() { // Arrange var mediaType1 = MediaTypeHeaderValue.Parse("application/json"); @@ -34,16 +35,45 @@ namespace Microsoft.AspNet.Mvc.Test } [Theory] - [InlineData("")] - [InlineData(null)] - [InlineData("invalid")] - public void ProducesAttribute_InvalidContentType_Throws(string content) + [InlineData("", "")] + [InlineData("application/xml,, application/json", "")] + [InlineData(", application/json", "")] + [InlineData("invalid", "invalid")] + [InlineData("application/xml,invalid, application/json", "invalid")] + [InlineData("invalid, application/json", "invalid")] + public void ProducesAttribute_UnParsableContentType_Throws(string content, string invalidContentType) { - // Act & Assert + // Act + var contentTypes = content.Split(',').Select(contentType => contentType.Trim()).ToArray(); + + // Assert var ex = Assert.Throws( - () => new ProducesAttribute(content)); - Assert.Equal("Invalid value '" + (content ?? "") + "'.", - ex.Message); + () => new ProducesAttribute(contentTypes[0], contentTypes.Skip(1).ToArray())); + Assert.Equal("Invalid value '" + (invalidContentType ?? "") + "'.", ex.Message); + } + + [Theory] + [InlineData("application/*", "application/*")] + [InlineData("application/xml, application/*, application/json", "application/*")] + [InlineData("application/*, application/json", "application/*")] + + [InlineData("*/*", "*/*")] + [InlineData("application/xml, */*, application/json", "*/*")] + [InlineData("*/*, application/json", "*/*")] + public void ProducesAttribute_InvalidContentType_Throws(string content, string invalidContentType) + { + // Act + var contentTypes = content.Split(',').Select(contentType => contentType.Trim()).ToArray(); + + // Assert + var ex = Assert.Throws( + () => new ProducesAttribute(contentTypes[0], contentTypes.Skip(1).ToArray())); + + Assert.Equal( + string.Format("The argument '{0}' is invalid. "+ + "Media types which match all types or match all subtypes are not supported.", + invalidContentType), + ex.Message); } private static void ValidateMediaType(MediaTypeHeaderValue expectedMediaType, MediaTypeHeaderValue actualMediaType) diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/ApiExplorerTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/ApiExplorerTest.cs index 846b9eb558..c832cfa5e0 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/ApiExplorerTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/ApiExplorerTest.cs @@ -597,63 +597,6 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Equal(typeof(JsonOutputFormatter).FullName, applicationJson.FormatterType); } - // uses [Produces("*/*")] - [Fact] - public async Task ApiExplorer_ResponseContentType_AllTypes() - { - // Arrange - var server = TestServer.Create(_provider, _app); - var client = server.CreateClient(); - - // Act - var response = await client.GetAsync("http://localhost/ApiExplorerResponseContentType/AllTypes"); - - var body = await response.Content.ReadAsStringAsync(); - var result = JsonConvert.DeserializeObject>(body); - - // Assert - var description = Assert.Single(result); - - var formats = description.SupportedResponseFormats; - Assert.Equal(4, formats.Count); - - var textXml = Assert.Single(formats, f => f.MediaType == "text/xml"); - Assert.Equal(typeof(XmlDataContractSerializerOutputFormatter).FullName, textXml.FormatterType); - var applicationXml = Assert.Single(formats, f => f.MediaType == "application/xml"); - Assert.Equal(typeof(XmlDataContractSerializerOutputFormatter).FullName, applicationXml.FormatterType); - - var textJson = Assert.Single(formats, f => f.MediaType == "text/json"); - Assert.Equal(typeof(JsonOutputFormatter).FullName, textJson.FormatterType); - var applicationJson = Assert.Single(formats, f => f.MediaType == "application/json"); - Assert.Equal(typeof(JsonOutputFormatter).FullName, applicationJson.FormatterType); - } - - [Fact] - public async Task ApiExplorer_ResponseContentType_Range() - { - // Arrange - var server = TestServer.Create(_provider, _app); - var client = server.CreateClient(); - - // Act - var response = await client.GetAsync("http://localhost/ApiExplorerResponseContentType/Range"); - - var body = await response.Content.ReadAsStringAsync(); - var result = JsonConvert.DeserializeObject>(body); - - // Assert - var description = Assert.Single(result); - - var formats = description.SupportedResponseFormats; - Assert.Equal(2, formats.Count); - - var textXml = Assert.Single(formats, f => f.MediaType == "text/xml"); - Assert.Equal(typeof(XmlDataContractSerializerOutputFormatter).FullName, textXml.FormatterType); - - var textJson = Assert.Single(formats, f => f.MediaType == "text/json"); - Assert.Equal(typeof(JsonOutputFormatter).FullName, textJson.FormatterType); - } - [Fact] public async Task ApiExplorer_ResponseContentType_Specific() { @@ -671,10 +614,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests var description = Assert.Single(result); var formats = description.SupportedResponseFormats; - Assert.Equal(1, formats.Count); + Assert.Equal(2, formats.Count); var applicationJson = Assert.Single(formats, f => f.MediaType == "application/json"); Assert.Equal(typeof(JsonOutputFormatter).FullName, applicationJson.FormatterType); + + var textJson = Assert.Single(formats, f => f.MediaType == "text/json"); + Assert.Equal(typeof(JsonOutputFormatter).FullName, textJson.FormatterType); } [Fact] diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/ConnegTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/ConnegTests.cs index cadcbeb8d9..6ceb500855 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/ConnegTests.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/ConnegTests.cs @@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests private readonly Action _app = new Startup().Configure; [Fact] - public async Task ProducesContentAttribute_SingleContentType_PicksTheFirstSupportedFormatter() + public async Task ProducesAttribute_SingleContentType_PicksTheFirstSupportedFormatter() { // Arrange var server = TestServer.Create(_provider, _app); @@ -40,7 +40,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests } [Fact] - public async Task ProducesContentAttribute_MultipleContentTypes_RunsConnegToSelectFormatter() + public async Task ProducesAttribute_MultipleContentTypes_RunsConnegToSelectFormatter() { // Arrange var server = TestServer.Create(_provider, _app); @@ -58,7 +58,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests } [Fact] - public async Task NoProducesContentAttribute_ActionReturningString_RunsUsingTextFormatter() + public async Task NoProducesAttribute_ActionReturningString_RunsUsingTextFormatter() { // Arrange var server = TestServer.Create(_provider, _app); @@ -76,7 +76,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests } [Fact] - public async Task NoProducesContentAttribute_ActionReturningAnyObject_RunsUsingDefaultFormatters() + public async Task NoProducesAttribute_ActionReturningAnyObject_RunsUsingDefaultFormatters() { // Arrange var server = TestServer.Create(_provider, _app); @@ -132,7 +132,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests } [Fact] - public async Task ProducesContentAttribute_OnAction_OverridesTheValueOnClass() + public async Task ProducesAttribute_OnAction_OverridesTheValueOnClass() { var server = TestServer.Create(_provider, _app); var client = server.CreateClient(); @@ -152,7 +152,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests } [Fact] - public async Task ProducesContentAttribute_OnDerivedClass_OverridesTheValueOnBaseClass() + public async Task ProducesAttribute_OnDerivedClass_OverridesTheValueOnBaseClass() { var server = TestServer.Create(_provider, _app); var client = server.CreateClient(); @@ -171,7 +171,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests } [Fact] - public async Task ProducesContentAttribute_OnDerivedAction_OverridesTheValueOnBaseClass() + public async Task ProducesAttribute_OnDerivedAction_OverridesTheValueOnBaseClass() { var server = TestServer.Create(_provider, _app); var client = server.CreateClient(); @@ -189,7 +189,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests } [Fact] - public async Task ProducesContentAttribute_OnDerivedAction_OverridesTheValueOnBaseAction() + public async Task ProducesAttribute_OnDerivedAction_OverridesTheValueOnBaseAction() { var server = TestServer.Create(_provider, _app); var client = server.CreateClient(); @@ -207,7 +207,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests } [Fact] - public async Task ProducesContentAttribute_OnDerivedClassAndAction_OverridesTheValueOnBaseClass() + public async Task ProducesAttribute_OnDerivedClassAndAction_OverridesTheValueOnBaseClass() { // Arrange var server = TestServer.Create(_provider, _app); @@ -224,8 +224,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests var body = await response.Content.ReadAsStringAsync(); Assert.Equal(expectedBody, body); } + [Fact] - public async Task ProducesContentAttribute_IsNotHonored_ForJsonResult() + public async Task ProducesAttribute_IsNotHonored_ForJsonResult() { // Arrange var server = TestServer.Create(_provider, _app); diff --git a/test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerResponseContentTypeController.cs b/test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerResponseContentTypeController.cs index 25b22422f5..c4115efe5b 100644 --- a/test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerResponseContentTypeController.cs +++ b/test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerResponseContentTypeController.cs @@ -15,28 +15,14 @@ namespace ApiExplorerWebSite } [HttpGet] - [Produces("*/*")] - public Product AllTypes() - { - return null; - } - - [HttpGet] - [Produces("text/*")] - public Product Range() - { - return null; - } - - [HttpGet] - [Produces("application/json")] + [Produces("application/json", "text/json")] public Product Specific() { return null; } [HttpGet] - [Produces("application/hal+json")] + [Produces("application/hal+json", "text/hal+json")] public Product NoMatch() { return null; diff --git a/test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerResponseTypeOverrideOnActionController.cs b/test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerResponseTypeOverrideOnActionController.cs index f457dfcf56..e32179b916 100644 --- a/test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerResponseTypeOverrideOnActionController.cs +++ b/test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerResponseTypeOverrideOnActionController.cs @@ -5,7 +5,7 @@ using Microsoft.AspNet.Mvc; namespace ApiExplorerWebSite { - [Produces("*/*", Type = typeof(Product))] + [Produces("application/json", Type = typeof(Product))] [Route("ApiExplorerResponseTypeOverrideOnAction")] public class ApiExplorerResponseTypeOverrideOnActionController : Controller { diff --git a/test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerResponseTypeWithAttributeController.cs b/test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerResponseTypeWithAttributeController.cs index 29c9cd7a2f..6608d4c792 100644 --- a/test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerResponseTypeWithAttributeController.cs +++ b/test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerResponseTypeWithAttributeController.cs @@ -16,7 +16,7 @@ namespace ApiExplorerWebSite } [HttpGet] - [Produces("*/*", Type = typeof(Product))] + [Produces("application/json", Type = typeof(Product))] public object GetObject() { return null; diff --git a/test/WebSites/ConnegWebSite/Startup.cs b/test/WebSites/ConnegWebSite/Startup.cs index f3075f4dce..12821f00e5 100644 --- a/test/WebSites/ConnegWebSite/Startup.cs +++ b/test/WebSites/ConnegWebSite/Startup.cs @@ -24,7 +24,9 @@ namespace ConnegWebSite options.AddXmlDataContractSerializerFormatter(); }); }); - + + app.UseErrorReporter(); + // Add MVC to the request pipeline app.UseMvc(routes => {