Search code examples
c#asp.net.netkatana

Using project katana what is the correct way to specify the startup class in web.config?


One of the ways of specifying the Startup class in Katana is through the owin:AppStartup key in appSettings in web.config

If the web.config file contains an appSetting with key=“owin:AppStartup”, the loader uses the setting value. The value must be a valid .NET-type name.
http://msdn.microsoft.com/en-us/magazine/dn451439.aspx

This is my web.config's app.settings:

<configuration>
  <appSettings>
    <add key="owin:AppStartup" value="MyStartup, MyAssemblyName"/>
  </appSettings>

Unfortunately I get this error:
The following errors occurred while attempting to load the app.
- For the app startup parameter value 'MyStartup, MyAssemblyName', the class 'MyStartup' was not found in assembly 'MyAssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

(I've tried with the fully qualified name, MyAssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, and I get the same error)

If I use the alternative of specifying the app startup class in the AssemblyInfo.cs file:

using MyAssemblyName;
...
[assembly:OwinStartup(typeof(MyStartup))]

It works without a problem.

What am I doing wrong?


Solution

  • My guess is you're missing a namespace:

    <configuration>
      <appSettings>
        <add key="owin:AppStartup" value="MyAssemblyName.MyStartup, MyAssemblyName"/>
      </appSettings>