2

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.

Rusell Gooc
  • 21
  • 1
  • 1
  • 3
  • Do you have declare `[assembly: OwinStartup(typeof(Bla))]`? See http://www.asp.net/aspnet/overview/owin-and-katana/owin-startup-class-detection – abatishchev Mar 10 '15 at 01:07
  • possible duplicate of [OWIN Startup Class Missing](http://stackoverflow.com/questions/20068075/owin-startup-class-missing) – abatishchev Mar 10 '15 at 01:08
  • @abatishchev : I do have it. – Rusell Gooc Mar 10 '15 at 01:16
  • Ok, so you have it. Is it being called? In what line do you receive the error? – abatishchev Mar 10 '15 at 01:20
  • @abatishchev, whenever i run it, i get the value of app as null. in the first startup class. – Rusell Gooc Mar 10 '15 at 01:21
  • Very very very late reply. But still, if it makes sense, the namespace of both your classes are different. So, they don't become a single class. Not sure why it didn't give you a build error mentioning 'unable to find Configure method'. – Sumesh Kuttan Feb 28 '18 at 09:31

1 Answers1

0
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.

Franz Wimmer
  • 1,418
  • 2
  • 18
  • 34
Rusell Gooc
  • 21
  • 1
  • 1
  • 3