Konrad Viltersten
Konrad Viltersten

Reputation: 39118

Configuration(IAppBuilder) not firing on start up

The configuration method below doesn't get fired.

using Microsoft.Owin;
using Owin;

[assembly: OwinStartupAttribute(typeof(SCM.Web.Startup))]
namespace SCM.Web
{
  public partial class Startup
  {
    public void Configuration(IAppBuilder builder) { }
  }
}

I've followed all the hints from here and it's a new project, not an upgrade. I can't for my life see how to get it to stop on the breakpoint and I'm in need to get more suggestions on how to troubleshoot it.

It's an intranet application so there's no logging in. The identity gets set to the Windows credentials, instead. I need to assign the roles so that only certain users can access certain actions in the controllers. I'm usually applying OWIN and application cookies, so that's the method I'm trying to follow here, as well.

Upvotes: 0

Views: 1724

Answers (2)

user1675891
user1675891

Reputation:

If you are running the website on an external IIS or maybe on the "real" IIS installed on your computer (and not the one that is fired up when you start the run), then it's likely that you're missing the breakpoint because the debugger isn't attached to the process yet when you pass by.

I think that you can confirm it by either checking the settings of your solution and projects or simply adding this code to the method that you don't think that you pass through.

throw new Exception("Killroy was here...");

Upvotes: 1

DavidG
DavidG

Reputation: 118977

You need an OwinStartup attribute to tell Owin what method to call. From the docs:

Used to mark which class in an assembly should be used for automatic startup.

Add one to your project, before the namespace declaration:

[assembly: OwinStartup(typeof(Your.Namespace.Startup))]
namespace Your.Namespace
{
    public partial class Startup
    {
      public void Configuration(IAppBuilder builder) { }
    }
}

There are some other methods to let Owin know which method (described here) but this is the simplest and probably the most common.

Upvotes: 3

Related Questions