简体   繁体   English

ASP.NET WEB API 启动类

[英]ASP.NET WEB API Startup class

I am currently using Ninject for the Dependency injection.我目前正在使用 Ninject 进行依赖注入。 This project is based on ASP.NET WEB APP 2. Whenever i run my application, i get the error {app null} in the startup.cs class.该项目基于 ASP.NET WEB APP 2。每当我运行我的应用程序时,我都会在 startup.cs 类中收到错误 {app null}。 and i have An unhandled exception of type 'System.StackOverflowException' occurred in Phase2_Group2_selucmps383_sp15_p2_g2.dll我在 Phase2_Group2_selucmps383_sp15_p2_g2.dll 中发生了类型为“System.StackOverflowException”的未处理异常

[assembly: OwinStartup(typeof(Phase2_Group2_selucmps383_sp15_p2_g2.Startup))]
    namespace Phase2_Group2_selucmps383_sp15_p2_g2
    {
        public partial class Startup
        {
            public void Configuration(IAppBuilder app)
            {
                Configuration(app);
            }
        }
    }

The App_Start startup.cs class is : App_Start startup.cs 类是:

namespace Phase2_Group2_selucmps383_sp15_p2_g2.App_Start
{
    public partial class Startup
    {
        public static string PublicClientId { get; private set; }

        public static Func<UserManager<IdentityUser>> UserManagerFactory { get; set; }

        public static OAuthAuthorizationServerOptions OAuthOptions { get; private set; }
        static Startup()
        {

            PublicClientId = "self";

            UserManagerFactory = () => new UserManager<IdentityUser>(new UserStore<IdentityUser>());

            OAuthOptions = new OAuthAuthorizationServerOptions
            {
                TokenEndpointPath = new PathString("/Token"),
                Provider = new ApplicationOAuthProvider(PublicClientId, UserManagerFactory),
                AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
                AllowInsecureHttp = true
            };

        }

        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();
            config.DependencyResolver = new NinjectResolver(NinjectWebCommon.CreateKernel());

            config.Routes.MapHttpRoute("default", "api/{controller}/{id}", new { id = RouteParameter.Optional });

            app.UseWebApi(config);



            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            app.UseOAuthBearerTokens(OAuthOptions);
            Configuration(app);
        }
    }
}

What is the issue here?这里有什么问题? Any help?有什么帮助吗? Would be happy to post anything else if needed.如果需要,很乐意发布其他任何内容。

public partial class Startup
{
    public void Configuration(IAppBuilder app)
    {
        ConfigAuth(app);
    }
}

also in the another startup.cs file, change the methdo name to the same as above.同样在另一个 startup.cs 文件中,将方法名称更改为与上面相同的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP.NET Core Web API,如何在启动类中访问 HttpContext - ASP.NET Core Web API, How can I access HttpContext in startup class asp.net Web API核心项目启动类里面的SetCompatibilityVersion是什么 - What is SetCompatibilityVersion inside of the startup class of asp.net Web API core project 在asp.net web Z8A5DA52ED126447D359E70C057项目中手动创建startup.cs class添加配置 - Adding configurations to manually created startup.cs class in asp.net web api project ASP.NET Web API和[Serializable]类 - ASP.NET Web API and [Serializable] class ASP.NET启动性能分析Web - ASP.NET startup Performance profiling web 在不同程序集中使用Startup.cs时,ASP.NET Core Web API返回404 - ASP.NET core web api returns 404 when Startup.cs in different assembly ASP.NET Web Api - Startup.cs 不存在 - ASP.NET Web Api - Startup.cs doesn't exist 如何在asp.net core 1.0 Web API的启动服务中创建后台任务? - How to create a background task in startup service in asp.net core 1.0 Web API? 如何激活 ASP.NET Core Web API 项目不是启动项目? - How to activate ASP.NET Core Web API project not as startup project? 如何为 ASP.NET 核心 Web API 应用程序编写程序和启动 cs 文件的单元测试 - How to write unit test for Program and Startup cs file for ASP.NET Core Web API app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM