C# 这条路线怎么了
鉴于以下情况:C# 这条路线怎么了,c#,azure,asp.net-web-api-routing,C#,Azure,Asp.net Web Api Routing,鉴于以下情况: namespace Foo.Controllers { [RoutePrefix("api/route")] public class SnoconesFooBarController : BaseApiController { /// <summary> /// Asks for a new foo to be created to the given subnet with the specific bar
namespace Foo.Controllers
{
[RoutePrefix("api/route")]
public class SnoconesFooBarController : BaseApiController
{
/// <summary>
/// Asks for a new foo to be created to the given subnet with the specific bar named
/// </summary>
/// <param name="fooName"></param>
/// <param name="uriString"></param>
/// <returns></returns>
[Route("newFoo/{fooName}")]
public async Task<IHttpActionResult> PostNewFooForSpecificBar(string fooName, string uriString)
{
}
}
为什么我在尝试发布到以下地址时会收到404:
具有以下有效载荷:
FWIW,我将其更改为如下所示:
namespace Foo.Controllers
{
[RoutePrefix("api/route")]
public class SnoconesFooBarController : BaseApiController
{
/// <summary>
/// Asks for a new foo to be created to the given subnet with the specific bar named
/// </summary>
/// <param name="fooData"></param>
/// <returns></returns>
[Route("newFoo/")]
public async Task<IHttpActionResult> PostNewFooForSpecificBar(FooRequestObject fooData)
{
}
}
包括我在FooRequestObject中需要的所有数据这是一个什么框架API/MVC等的路由,我将问题改为更精细的@ErikPhilips您的变量名是sourceName而不是fooName是否重要?这似乎是MVC项目中的APIController。@ErikPhilips它对我的所有其他路由都很有效。