小编Jör*_*eyn的帖子

命名空间重构MVC WebAPI后的两个路由

我为我的整个项目重命名了我的命名空间.一切仍然正常,但我的WebAPI现在为我的控制器找到两条路线.

Multiple types were found that match the controller named 'department'.
This can happen if the route that services this request ('api/{controller}/{id}') found multiple controllers defined with the same name but differing namespaces, which is not supported.

The request for 'department' has found the following matching controllers:
A***.P***.Benutzerverwaltung.Jo***MVC.Controllers.DepartmentController
A***.Benutzerverwaltung.API.Controllers.DepartmentController
Run Code Online (Sandbox Code Playgroud)

所以我将第一个命名空间重命名为第二个命名空间,我在各处搜索旧命名空间,但没有找到任何内容.那么,我该怎么办?

感谢帮助.

c# asp.net-mvc asp.net-web-api

5
推荐指数
1
解决办法
1628
查看次数

使用if/else条件处理多个列表 - 递归

我有许多列表包含一个或多个对象,如果列表中有多个对象,它应该做一些事情.当列表中只有一个对象时,请取第二个列表并执行相同操作.这应该发生在4个列表中.这是我的解决方案,但我认为这是一个糟糕的解决方案.处理此代码有更好的方法吗?

if (list1.Count > 1)
    for (int i = 0; i < list1.Count; i++)
    {
        DoSomething(list1);
    }
else
{
    if (list2.Count > 1)
        for (int i = 0; i < list2.Count; i++)
        {
            DoSomething(list2);
        }
    else
    {
        if (list3.Count > 1)
            for (int i = 0; i < list3.Count; i++)
            {
                DoSomething(list3);
            }
        else
        {
        ...
Run Code Online (Sandbox Code Playgroud)

非常感谢和最诚挚的问候,Joerg

c# recursion

0
推荐指数
1
解决办法
216
查看次数

标签 统计

c# ×2

asp.net-mvc ×1

asp.net-web-api ×1

recursion ×1