Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Can';t访问操作Web API-路由属性继承-ASP.NET核心控制器_C#_Api_Web_Post_Routes - Fatal编程技术网

C# Can';t访问操作Web API-路由属性继承-ASP.NET核心控制器

C# Can';t访问操作Web API-路由属性继承-ASP.NET核心控制器,c#,api,web,post,routes,C#,Api,Web,Post,Routes,我有三个级别的路由属性继承: A类:B类 公共字符串Concat(…) [路线(……)] B类:C类 [路线(……)] ClasseC:控制器数据库 问题是ClasseA中的服务“conact”永远不起作用 以下是我的代码和详细信息: UniteAdministrativeController: public class UniteAdministrativeController : ControleurRechercheBase<Entites.UniteAdministrative

我有三个级别的路由属性继承:

A类:B类 公共字符串Concat(…) [路线(……)] B类:C类 [路线(……)] ClasseC:控制器数据库

问题是ClasseA中的服务“conact”永远不起作用

以下是我的代码和详细信息:

  • UniteAdministrativeController:

     public class UniteAdministrativeController : ControleurRechercheBase<Entites.UniteAdministrative, DbContext>     
    {
          protected readonly IRechercheDAO<Entites.UniteAdministrative, DbContext> rechercheDAOtest;
          public UniteAdministrativeController(IRechercheDAO<Entites.UniteAdministrative, DbContext> rechercheDAO)
     : base( rechercheDAO)
     {
         rechercheDAOtest = rechercheDAO;
     }      
    
     [HttpPost]
     [Route("Concat")]
    
     public string Concat([FromBody] CritereRecherche critereRecherche)
     {
         //...
     }
    
    公共类UniteAdministrativeController:ControleurRechercheBase
    {
    受保护的只读IRechercheDAO rechercheDAOtest;
    公共单位行政控制器(IRechercheDAO rechercheDAO)
    :base(rechercheDAO)
    {
    rechercheDAOtest=rechercheDAO;
    }      
    [HttpPost]
    [路线(“Concat”)]
    公共字符串Concat([FromBody]CriteRecherche CriteRecherche)
    {
    //...
    }
    
    }

  • ControleurRechercheBase

      [Route("api/v{version:apiVersion}/[controller]")]
       public abstract class ControleurRechercheBase<TEntite, TContexte> : ControleurObtentionBase<TEntite>
          where TEntite : class
          where TContexte : ContexteBase
     {
          protected readonly IRechercheDAO<TEntite, TContexte> RechercheDao;
    
          protected ControleurRechercheBase(IRechercheDAO<TEntite, TContexte> rechercheDAO);
    
      [HttpPost("Recherche")]
      public Task<IActionResult> Rechercher([FromBody] CritereRecherche critereRecherche);
     }
    
    [路由(“api/v{version:apiVersion}/[控制器]”)
    公共抽象类ControleurRechercheBase:ControlEurobtEntationBase
    TEntite所在地:班级
    其中TContexte:ContexteBase
    {
    受保护的只读IRechercheDAO RechercheDao;
    受保护的ControleurRechercheBase(IRechercheDAO rechercheDAO);
    [HttpPost(“Recherche”)]
    公共任务记录程序([FromBody]CriteRecherche CriteRecherche);
    }
    
  • ControlEurobtationBase:

      [Route("api/v{version:apiVersion}/[controller]")]
       public abstract class ControleurObtentionBase<T> : ControleurBase where T : class
    {           
    
         protected ControleurObtentionBase();
    
      [HttpGet]
      [HttpGet("{parametre}")]
      [ProducesAttribute("application/json", new[] { })]
    
      public Task<IActionResult> Get(string parametre);
    
    [路由(“api/v{version:apiVersion}/[控制器]”)
    公共抽象类ControlEurobTimeBase:ControleurBase,其中T:class
    {           
    受保护的控制EurobtationBase();
    [HttpGet]
    [HttpGet(“{parametre}”)]
    [产品属性(“应用程序/json”,新[]{}]
    公共任务获取(字符串参数);
    
    }

我的问题是我无法执行HTTPPOST“Concat”操作, 当我用邮递员测试它时: https://localhost:44339/api/v1.0/UniteAdministrative/

我得到错误415

我怎样才能修好它?
或者修改它的想法?

错误415是不受支持的媒体类型。因此,标题中的内容类型与正文中的数据不匹配。我会使用像wireshark或fiddler这样的嗅探器来更好地了解您实际发送的内容。查看第一个请求的标题和正文。