简体   繁体   中英

ASP.NET WEB API Startup class

I am currently using Ninject for the Dependency injection. 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. and i have An unhandled exception of type 'System.StackOverflowException' occurred in Phase2_Group2_selucmps383_sp15_p2_g2.dll

[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 :

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM