What makes a Visual Studio 2013 Project a katana project?

I just started my struggle to understand the barn and katana. Following the Asp.Net tutorial, I created an empty asp.net project in VS2013 and added the Nuget package link to Microsoft.Owin.Host.SystemWeb . The project that I created is empty as shown.

enter image description here

There is nothing but AssemblyInfo.cs , Web.config and packages.config . Now when I run (F5), it says

  • There is no assembly containing OwinStartupAttribute.
  • No assembly was found containing the Startup class or [AssemblyName] .Startup. To disable OWIN startup detection, add appSetting owin: AutomaticAppStartup with the value "false" in your web.config. To specify the start, class, or OWIN method, add appSetting owin: AppStartup with the full start class or the name of the configuration method in the web.config file.

Now the question is this: adding a link to Nuget on Microsoft.Owin.Host.SystemWeb , he started looking for something specific for Owin as a Startup class and so on, as indicated in the error message? I mean, I was running another project without this Nuget link, and the error message is completely different. Nothing seems to have changed in at least two AssemblyInfo.cs , Web.config files by adding a Nuget link. As far as I understand, the addition of Nuget added the package.config file and added some link to the project. I also compared the project properties for the tab of two projects by tab, and I did not find the difference! Therefore, I wonder what the Owin project calls for the Startup class in the world?

+6
source share
1 answer

The secret is that Katana uses an ASP.NET feature called PreAppStart. Here you can see the source code:

https://katanaproject.codeplex.com/SourceControl/latest#src/Microsoft.Owin.Host.SystemWeb/PreApplicationStart.cs

If the assembly in an ASP.NET application has this assembly level attribute:

 [assembly: PreApplicationStartMethod(typeof(PreApplicationStart), "Initialize")] 

Then ASP.NET will automatically run this code when the application starts. This code will be run before the user code is run before the Application_Start event. That's why it was called PreAppStart.

In the case of Katana, this code dynamically registers the ASP.NET HTTP module ( IHttpModule ), which will ultimately look up and try to call the application launch / creation class. And if that fails, Kablamo!

To disable automatic behavior, add this line to web.config in the <appSettings> section:

 <add key="owin:AutomaticAppStartup " value="false" /> 

More information about this behavior can be found at www.asp.net: http://www.asp.net/aspnet/overview/owin-and-katana/owin-startup-class-detection (same as the commentator mentioned) )

+4
source

Source: https://habr.com/ru/post/975695/


All Articles