Owin with EPiServer Alloy

Vote:
 

I've installed the latest version of Alloy from the VS template.

Then I intalled the Microsoft.Owin.Host.SystemWeb package, and created the startup file for owin like this:

using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof(EPiServerSite1.Startup1))]

namespace EPiServerSite1
{
    public class Startup1
    {
        public void Configuration(IAppBuilder app)
        {
            // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
            app.Run(context =>
            {
                context.Response.ContentType = "text/plain";
                return context.Response.WriteAsync("Hello, world.");
            });
        }
    }
}

I set a breakpoint at the app.run line, just to see if it hits. The file isn't going to contain this code, I just wanted to see if the file was run.

But it doesn't work. Do I have to do any additional setup to get Owin working?

#154836
Aug 31, 2016 9:18
Vote:
 

Hi,

What do you mean with "it doesn't work"? I guess Episerver's routing is kicking in so if you want to try Owin out you need to do that on a mapped URL.

#154838
Aug 31, 2016 9:59
Vote:
 

I mean that the startup file is never run. The breakpoint in there never trigger.

Can Owin only run on a specifc url?

#154839
Aug 31, 2016 10:03
Vote:
 

I gues Owin is a module that runs ontop of everything, but you can map a URL to do something like this:

 app.Map("/util/logout.aspx", map => map.Run(ctx =>
{
     // Do you stuff

     return Task.FromResult(0);
}));
#154842
Aug 31, 2016 10:14
Vote:
 

The problem is that the configuration method is never executed as far as I can tell.

I have tried different configs, but so far no luck.

#154843
Aug 31, 2016 10:18
Vote:
 

Perhaps some guidance? http://stackoverflow.com/questions/20203982/owinstartup-not-firing

#154844
Aug 31, 2016 11:27
Vote:
 

I have the reference to Microsoft.Owin.Host.SystemWeb in the project. I don't think that's the issue, but thanks!

#154848
Aug 31, 2016 13:11
Vote:
 

Now I'm trying this with no luck:

public void Configuration(IAppBuilder app)
{
     throw new Exception();
}
#154849
Aug 31, 2016 13:15
Vote:
 

Think I fixed it by running it on IIS instead of just pressing F5 in VS.

Johan Björnfot set me on the right track with one of the answers on StackOverflow.

#154861
Aug 31, 2016 15:37
Vote:
 

Should work on IIS Express though, we usually use Express in development and Owin works just fine.

#154862
Aug 31, 2016 15:38
Vote:
 

Johan: Hmm, strange.

Also, I now uninstalled and reinstalled the owin packages again, and it stopped working again.

#154864
Edited, Aug 31, 2016 16:02
Vote:
 

I got issues while ago when working with ServiceApi in IIS Express. Routes were not registered and Owin startup was not fired. Sometimes it worked, sometimes it didn't. Switched to IIS with no further issues. I found that clearing IIS Express cache and restarting the service - sometimes might help. Weird thing is this express :)

#154875
Aug 31, 2016 21:40
* 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.