Fixing action selection with complex types - MVC scenarios with more than one parameter are broken right now

This commit is contained in:
Ryan Nowak 2014-05-09 17:45:45 -07:00
parent 88be38a506
commit b9dbb6fe57
2 changed files with 24 additions and 4 deletions

View File

@ -1,4 +1,5 @@
using Microsoft.AspNet.Mvc;
using MvcSample.Web.Models;
namespace MvcSample.Web
{
@ -26,5 +27,22 @@ namespace MvcSample.Web
{
return _result.Content("Get(id, name)", null, null);
}
public ActionResult WithUser()
{
return _result.Content("WithUser()", null, null);
}
// Called for all posts regardless of values provided
[HttpPost]
public ActionResult WithUser(User user)
{
return _result.Content("WithUser(User)", null, null);
}
public ActionResult WithUser(int projectId, User user)
{
return _result.Content("WithUser(int, User)", null, null);
}
}
}

View File

@ -7,6 +7,7 @@ using System.Diagnostics.Contracts;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc.Core;
using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Routing;
using Microsoft.Framework.DependencyInjection;
@ -56,10 +57,6 @@ namespace Microsoft.AspNet.Mvc
{
return null;
}
else if (matching.Count == 1)
{
return matching[0];
}
else
{
return await SelectBestCandidate(context, matching);
@ -99,6 +96,11 @@ namespace Microsoft.AspNet.Mvc
foreach (var parameter in action.Parameters.Where(p => p.ParameterBindingInfo != null))
{
if (!ValueProviderResult.CanConvertFromString(parameter.ParameterBindingInfo.ParameterType))
{
continue;
}
if (await actionBindingContext.ValueProvider.ContainsPrefixAsync(parameter.ParameterBindingInfo.Prefix))
{
candidate.FoundParameters++;