私は、サービス要求を受け入れるために、次のアクションコードを持っている:ASP.NETのWebサービス、パラメータ文字列
namespace MyStuff.api
{
[RoutePrefix("api/Dy")]
[EnableCors(origins: "*", headers: "*", methods: "*")]
[Authorize]
public class DyController : ApiController
{
//...
[Route("{pit}/{name}")]
public void Post(string pit, string name, [FromBody]JObject obj)
{
//...
#region do something
// work with name here
#endregion
}
//...
}
}
テストシナリオ
私はデバッガでだとブレークポイントが内のどこかに設定されています投稿メソッド。データセットでは、私はブランド名「3.1 Phillip Lim」を見つけました。私は投稿メソッドがヒットするようにこの名前(および他の同様のクリエイティブな名前)をどのように操作できるかを調べようとします。
ブレークポイントがヒットしない - 要求はPost
方法で
- $.post("http://undisclosed.server.net/api/Dy/Brands/3.1%20Phillip%20Lim", MyStuff.Brands[30], function (result) { MyStuff.BrandsResult = result; })
- $.post("http://undisclosed.server.net/api/Dy/Brands/-3.1%20Phillip%20Lim", MyStuff.Brands[30], function (result) { MyStuff.BrandsResult = result; })
- $.post("http://undisclosed.server.net/api/Dy/Brands/id-3.1%20Phillip%20Lim", MyStuff.Brands[30], function (result) { MyStuff.BrandsResult = result; })
- $.post("http://undisclosed.server.net/api/Dy/Brands/body.Name", MyStuff.Brands[30], function (result) { MyStuff.BrandsResult = result; })
- $.post("http://undisclosed.server.net/api/Dy/Brands/{body.Name}", MyStuff.Brands[30], function (result) { MyStuff.BrandsResult = result; })
に到着していないブレークポイントがヒット - の型の認識のいくつかの種類であるかもしれない - 期待
$.post("http://undisclosed.server.net/api/Dy/Brands/body-Name", MyStuff.Brands[30], function (result) { MyStuff.BrandsResult = result; })
$.post("http://undisclosed.server.net/api/Dy/Brands/{null}", MyStuff.Brands[30], function (result) { MyStuff.BrandsResult = result; })
WEBAPI 2は明らかに裏で何かをするよう要求が到着URL内のセグメント...
どういうことが起こっているのか、どう対処したか説明してください。ありがとう。