Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/280.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# Windows Azure Dnn Web API路由未注册_C#_.net_Azure_Dotnetnuke - Fatal编程技术网

C# Windows Azure Dnn Web API路由未注册

C# Windows Azure Dnn Web API路由未注册,c#,.net,azure,dotnetnuke,C#,.net,Azure,Dotnetnuke,我正在使用angularJS在DotNetNuke上实现一个模块。我已经在本地测试了该模块,它工作正常,但是一旦我在生产环境中安装了该模块,我就会返回此错误: [WebAddress]/Programs/DesktopModules/Controls/Programs/ProgramApi/GetList?categoryId=-1&index=0&results=20 404 (Not Found) 是否需要采取步骤才能在azure中注册这些路由 Web Api names

我正在使用angularJS在DotNetNuke上实现一个模块。我已经在本地测试了该模块,它工作正常,但是一旦我在生产环境中安装了该模块,我就会返回此错误:

[WebAddress]/Programs/DesktopModules/Controls/Programs/ProgramApi/GetList?categoryId=-1&index=0&results=20 404 (Not Found) 
是否需要采取步骤才能在azure中注册这些路由

Web Api

namespace HyperLib.Modules.Programs.Services
{
    [SupportedModules("Programs")]
    public class ProgramApiController : DnnApiController
    {
 [HttpGet, ValidateAntiForgeryToken]
        [DnnModuleAuthorize(AccessLevel = DotNetNuke.Security.SecurityAccessLevel.View)]
        public HttpResponseMessage GetList(int categoryId, int index, int results)
        {
            try
            {
                Components.ProgramController pc = new Components.ProgramController();

                bool isEditable = false;
                if (DotNetNuke.Common.Globals.IsEditMode() && ModulePermissionController.CanEditModuleContent(this.ActiveModule))
                    isEditable = true;

                if (categoryId != -1)
                {
                    var programs = pc.GetItemsByCondition<Program>("where ModuleId = @0 and ProgramCategoryId = @1", this.ActiveModule.ModuleID, categoryId)
                        .Where(w => w.EndDate >= DateTime.Now)
                        .Skip(index * results)
                        .Take(results)
                        .Select(s => new ProgramViewModel(s, false, isEditable, this.ActiveModule.ModuleID.ToString(), this.ActiveModule.TabID.ToString()));
                    return Request.CreateResponse(HttpStatusCode.OK, JsonConvert.SerializeObject(programs));
                }
                else
                {
                    var programs = pc.GetItems<Program>(this.ActiveModule.ModuleID)
                       .Where(w => w.EndDate >= DateTime.Now)
                       .Skip(index * results)
                       .Take(results)
                       .Select(s => new ProgramViewModel(s, false, isEditable, this.ActiveModule.ModuleID.ToString(), this.ActiveModule.TabID.ToString()));
                    return Request.CreateResponse(HttpStatusCode.OK, JsonConvert.SerializeObject(programs));
                }

            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "{ }");
            }
        }

我终于解决了这个问题,以防其他人发现这个问题。我的注册路由过载以前是这样的

        mapRouteManager.MapHttpRoute(
            moduleFolderName: "Programs",
            routeName: "Programs",
            url: "{controller}/{action}",
            defaults: new { controller = "ProgramApi", action = "GetList", id = System.Web.Mvc.UrlParameter.Optional },
            namespaces: new string[] { "[Namespace]" });
为了通过Azure注册路由,由于某些原因,此重载不起作用。我不得不把它改成这样:

        mapRouteManager.MapHttpRoute("Programs",
                    "default",
                    "{controller}/{action}",
                    new[] { "HyperLib.Modules.Programs.Services" });
        mapRouteManager.MapHttpRoute("Programs",
                    "default",
                    "{controller}/{action}",
                    new[] { "HyperLib.Modules.Programs.Services" });