ASP.NET WEB API启动类

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (1)
  • 关注 (0)
  • 查看 (181)

我目前正在使用Ninject进行依赖注入。这个项目基于ASP.NET WEB APP 2.每当我运行我的应用程序时,我在startup.cs类中得到错误{app null}。我有一个未处理的异常类型'System.StackOverflowException'发生在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);
            }
        }
    }

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);
        }
    }
}

这是为什么?求助谢谢!

提问于
用户回答回答于
public partial class Startup
{
    public void Configuration(IAppBuilder app)
    {
        ConfigAuth(app);
    }
}

同样在另一个startup.cs文件中,将methdo名称更改为与上面相同。

扫码关注云+社区

领取腾讯云代金券

年度创作总结 领取年终奖励