Adding OWIN startup class to new empty episerver site

Vote:
 

Hi,

I am trying to add a standard OWIN startup class to my episerver website but the code is not being hit when i run the site. I have cretaed a startup class (startup.cs) in the root of the application and added the attribute '[assembly: OwinStartup(typeof(Site.Web.Startup))]', i have installed the nuget package 'Microsoft.Owin.Host.SystemWeb', i have tried both with and without the web.config appsettings '<add key="owin:AutomaticAppStartup" value="true" />' and '<add key="owin:appStartup" value="Site.Web.Startup" />' but when i run the application, and go to the homepage for instance, i am not seeing the code in the startup.cs being run. At the moment the code in the startup is just this, for testing purposes:

app.Run(context =>
{
context.Response.ContentType = "text/plain";
return context.Response.WriteAsync("Sam testing 123 123 123.");
});


I have checked the application pool in iis and it is definitely using .net v4 and in integrated mode.

I have created a new alloy site on the same machine and set it to run in iis and the startup class is definitely being triggered, so i think it must be something to do with the setup of the episerver site when you selet 'empty site'. 

Can anyone think of anything else i can do to make this episerver website trigger the startup class? I'm out of ideas but i know it must be possible.

Sam

#202653
Edited, Mar 28, 2019 13:50
Vote:
 

Hi Sam

I have solved this issue a couple of times, but because I rarely come across it, I don't recall exactly how I solved it last time.

But I would first check these things:

  • Is the method hit if you use IIS Express?
  • Is the Microsoft.Owin.Host.SystemWeb.dll file copied to the bin folder on build?
  • Have you tried clearing the temp files in C:\Windows\Microsoft.NET\Framework\v4.0.30319?

The configuration entries (owin:AutomaticAppStartup and owin:appStartup) is not needed, when you use the attribute, OwinStartup.

#202725
Mar 29, 2019 12:16
Vote:
 

I would try copying the startup file from alloy and strip it from unneccessary things and then add all nuget packages that alloy uses.

After that works, I would strip it and remove all nuget packages I don't need. Might be a typo in an attribute somewhere. Might be a nuget package that wasn't installed correctly...

#202897
Apr 03, 2019 10:41
Vote:
 

Hi,

I tried the suggestions posted but nothing solved my problem. After a lot of tinkering i found the source of the issue. My Web.Config had the follwoing elelment in it:

<compilation debug="true" targetFramework="4.6.2" optimizeCompilations="true" />

when i changed optimizeCompilations to false the startup class was suddenly working. I'm not completely sure what this setting does but if anyone else is having the same problem i'd recommend checking the compilation element of the web.config.

Sam

#203231
Apr 12, 2019 10:02
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.