System.InvalidOperationException:“Sequence contains more than one matching element”
我在使用asp.net core 2.0 , 使用 httpServer 中。报错。如下图。
var route_config = new List<Route>() {
new Route {
Name = "API_Assembly_Execution",
UrlRegex = @"^/AssemblyExecution/AddAssemblyExecution",
Method = "POST",
Callable = new API.API_Assembly_Execution().Handle,
},
new Route {
Name = "API_Assembly_AddFinishedAssembly",
UrlRegex = @"^/AssemblyExecution/AddAssembly",
Method = "POST",
Callable = new API.API_Assembly_AddFinishedAssembly().Handle,
}, };
int port = 1122,
httpServer = new HttpServer(port, route_config);
Thread thread = new Thread(new ThreadStart(httpServer.Listen));
thread.Start();
经发现,这个前半部分一样,冲突了。
解决办法:
将后面的名称改一下:
new Route {
Name = "API_Assembly_AddFinishedAssembly",
UrlRegex = @"^/AssemblyExecution/SaveAssembly",
Method = "POST",
Callable = new API.API_Assembly_AddFinishedAssembly().Handle,
},
即测试成功!