Sorunum çok ilginç. Benim kodum;Web Api <T> Yöntem
public JsonResult<ResultStatus> Post<T>(string query, [FromBody]T value) where T: GelYikaBase
{
return Json(new ResultStatus());
}
Benimle çalışmak istiyorum, bu veritabanının herhangi bir nesnesini kaydetmenin tek yöntemi. Ancak, URL'lerin bir işlevini bu şekilde nasıl ekleyeceğimi bilmiyorum.
Hata; Senin durumunda
// My generic method
void GenericMethod<T>(){}
...
// Call the generic method by specifying the type of T:
GenericMethod<string>()
:
jenerik yaygın bir kullanım şöyle olabilir:
{"Message": "An error has occurred."
"ExceptionMessage": "Cannot call action method 'System.Web.Http.Results.JsonResult`1[GelYikaFreamwork.Data.ResultStatus] Post[T](System.String, T)' on controller 'Gel_Yıka_Servis.Controllers.ServisController' because the action method is a generic method."
"ExceptionType": "System.InvalidOperationException"
"StackTrace": " konum: System.Web.Http.Controllers.ReflectedHttpActionDescriptor.InitializeActionExecutor(MethodInfo methodInfo) konum: System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<InitializeProperties>b__4() konum: System.Lazy`1.CreateValue() konum: System.Lazy`1.LazyInitValue() konum: System.Lazy`1.get_Value() konum: System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken) --- Özel durumun oluşturulduğu önceki konumdan başlayan yığın izlemesinin sonu --- konum: System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) konum: System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) konum: System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() konum: System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext() --- Özel durumun oluşturulduğu önceki konumdan başlayan yığın izlemesinin sonu --- konum: System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) konum: System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) konum: System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() konum: System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext() --- Özel durumun oluşturulduğu önceki konumdan başlayan yığın izlemesinin sonu --- konum: System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) konum: System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) konum: System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() konum: System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
}
problemi, kontrol cihazınızın bağlamak için hangi modeli bilmediğidir. reflectedhttpdescriptor sınıfına bir göz atmalısınız. Belki de modellerinize bağlamak için varsayılan behavipr'ı geçersiz kılabilirsiniz. – Thomas
Nasıl yapmalıyım? –
Cevabınız – Thomas