Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Error when using RouteAttribute and HttpPost together on same action #1194

Closed
@DamianEdwards

Description

@DamianEdwards

Microsoft.AspNet.Mvc.Routing (1.0.0-beta1-10401)

Repro Steps

  • Create a new ASP.NET vNext MVC project using the project template
  • Add the following action method declaration to the HomeController:
[Route("foo")]
[HttpPost]
public IActionResult Foo()
{
    return View();
}
  • Launch the application from VS

Expected Results

The site runs

Actual Results

A Helios error is displayed with the following details:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: The following errors occurred with attribute routing information:

Error 1:
A method 'MusicStore.Apis.AlbumsApiController.CreateAlbum' must not define attribute routed actions and non attribute routed actions at the same time:
Action: 'MusicStore.Apis.AlbumsApiController.CreateAlbum' - Template: 'api/albums'
Action: 'MusicStore.Apis.AlbumsApiController.CreateAlbum' - Template: '(none)'
 at Microsoft.AspNet.Mvc.ReflectedActionDescriptorProvider.Build(ReflectedApplicationModel model)
 at Microsoft.AspNet.Mvc.ReflectedActionDescriptorProvider.GetDescriptors()
 at Microsoft.AspNet.Mvc.ReflectedActionDescriptorProvider.Invoke(ActionDescriptorProviderContext context, Action callNext)
 at Microsoft.Framework.DependencyInjection.NestedProviders.NestedProviderManager`1.CallNext.CallNextProvider()
 at Microsoft.Framework.DependencyInjection.NestedProviders.NestedProviderManager`1.Invoke(T context)
 at Microsoft.AspNet.Mvc.DefaultActionDescriptorsCollectionProvider.GetCollection()
 at Microsoft.AspNet.Mvc.DefaultActionDescriptorsCollectionProvider.get_ActionDescriptors()
 at Microsoft.AspNet.Mvc.Routing.AttributeRouting.GetActionDescriptors(IServiceProvider services)
 at Microsoft.AspNet.Mvc.Routing.AttributeRouting.CreateAttributeMegaRoute(IRouter target, IServiceProvider services)
 at Microsoft.AspNet.Builder.BuilderExtensions.UseMvc(IApplicationBuilder app, Action`1 configureRoutes)
 at Microsoft.AspNet.Builder.BuilderExtensions.UseMvc(IApplicationBuilder app)
 at MusicStore.Spa.Startup.Configure(IApplicationBuilder app) in C:\src\GitHub\AspNet\MusicStore\src\MusicStore.Spa\Startup.cs:line 66
 --- End of inner exception stack trace ---
 at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
 at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
 at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
 at Microsoft.AspNet.Hosting.Startup.StartupLoader.<>c__DisplayClass0.<LoadStartup>b__3(IApplicationBuilder builder)
 at Microsoft.AspNet.Loader.IIS.KlrHttpApplication.HeliosStartupLoaderProvider.WrappingStartupLoader.<>c__DisplayClass0.<LoadStartup>b__1(IApplicationBuilder builder)
 at Microsoft.AspNet.Hosting.HostingEngine.EnsureApplicationDelegate(HostingContext context)
 at Microsoft.AspNet.Hosting.HostingEngine.Start(HostingContext context)
 at Microsoft.AspNet.Loader.IIS.KlrHttpApplication.ApplicationStart(IHttpApplication application)
 at Microsoft.AspNet.Loader.IIS.HttpApplicationBase.InvokeApplicationStart(IHttpApplication application)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions