鍍金池/ 問答/C#/ aspnetcore 中分支管道 使用map 卻不能進入控制器

aspnetcore 中分支管道 使用map 卻不能進入控制器

請求地址:http://localhost:54876/services/datetime?            cpid=zhongzhiyd3&sid=363&mobile=17318200541&age=1
代碼:
 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        app.Map("/services", HandleMapTest1);
        app.Map("/service1", HandleMapTest2);

        //RunProgram().GetAwaiter().GetResult();
    }
    private static void HandleMapTest1(IApplicationBuilder app)
    {
        app.UseHistorySuccessRecord();
        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });
    }
    private static void HandleMapTest2(IApplicationBuilder app)
    {
        app.UsePartnerSignIn();
        app.UseRedisBlackTel();
        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });
    }
    
    控制器代碼:
    
    public JsonResult datetime(string name, int age)
    {
        //var connstr = _configuration["DataBaseConfig:ConnectDb"];
        //var dt = DbHelper.LoadDataTable(connstr, "select * from tbl_order where createdate>'2018-2-28'");
        //foreach(DataRow dr in dt.Rows)
        //{
        //    var id = dr["id"].ToString();
        //}
        var model = new time()
        {
            name = name,
            age = age,
            timestr = DateTime.Now.ToString()
        };
        _logger.LogInformation(DateTime.Now.ToString());
        return Json(model);
    }
回答
編輯回答
糖果果

具體訪問的Controller的代碼也看一看

2017年7月24日 16:36
編輯回答
小眼睛

控制器的路由配置貼一下?

2018年6月10日 00:00