I'm hoping someone can help me, I have a method that I want to run on start up. I've looked at similar topics and made the changes that I thought would fix my issue, unfortunately not - The method in question is never executed when I start my application. Any help is greatly appreciated :)
using Microsoft.AspNet.Identity;
using Microsoft.Owin;
using Microsoft.Owin.Security.Cookies;
using Owin;
using Umbraco.Core;
[assembly: OwinStartup("ConfigureAuth",typeof(UmbracoIntV2.App_Start.UmbracoIdentityStartup))]
namespace UmbracoIntV2.App_Start
{
public class UmbracoIdentityStartup : ApplicationEventHandler
{
public void ConfigureAuth(IAppBuilder app)
{
//some code
}
}
}
I have a similar issue using Umbraco 7.3.4. I'm trying to use SignalR but I'm so far been unable to run the code in the Configuration method below. I've added a breakpoint on the base.Configuration(app) line but this never gets hit
using Microsoft.Owin;
using Owin;
using Umbraco.Web;
[assembly: OwinStartup("BenTestStartup", typeof(Intranet2.App_Start.Startup))]
namespace Intranet2.App_Start
{
public class Startup : UmbracoDefaultOwinStartup
{
public override void Configuration(IAppBuilder app)
{
base.Configuration(app);
app.MapSignalR();
}
}
}
I have remove the default and added the key to the web.config
Yes, this is still an issue for me. Fortunately, the requirement to use SignalR has been dropped, but I will need to get this going again in the near future.
I tinkered with things a bit... I tried a brand new Web Application in Visual Studio, and then installed Umbraco through NuGet (7.4.1 I think), and then SignalR, but I still couldn't get the breakpoint to be hit. If I installed SignalR straight into a Mvc application (not Umbraco), then the breakpoint would be hit. If the requirement to use SignalR had still existed, I was going to try to call app.MapSignalR from within an ActionFilter or an AuthorisationFilter (as I would have done in Mvc).
As you say my code looks fine (and I've repeated on another project), I suppose I could have missed something somewhere along the line.
Does a working version of an Umbraco Solution file with SignalR installed exist which I can download to test locally?
same issue for me on 7.4.1 i want to use my own startup .. removing "owin:appStartup":"UmbracoDefaultOwinStartup" breaks the backoffice but my startup class is hit. adding it back in means my startup is never hit.
EDIT: worked it out. durrhhh. stupid me.
Create a Startup.cs and comment out "owin:appStartup":"UmbracoDefaultOwinStartup" , OWIN obviously looks for Startup by default.
just need to inherit UmbracoDefaultOwinStartup
using System;
using Microsoft.Owin;
using Owin;
using Umbraco.Web;
[assembly: OwinStartup(typeof(Startup))]
namespace My.Site
{
public class Startup : UmbracoDefaultOwinStartup
{
public new void Configuration(IAppBuilder app)
{
base.Configuration(app);
//my own startup functions
}
}
}
[assembly: OwinStartup("UmbracoStandardOwinStartup", typeof(UmbracoStandardOwinStartup))]
public class UmbracoStandardOwinStartup : UmbracoDefaultOwinStartup
{
OWIN Startup
Hi all,
I'm hoping someone can help me, I have a method that I want to run on start up. I've looked at similar topics and made the changes that I thought would fix my issue, unfortunately not - The method in question is never executed when I start my application. Any help is greatly appreciated :)
Hello,
Have a look at the Hybrid Framework. This code runs on startup: https://github.com/jbreuer/Hybrid-Framework-for-Umbraco-v7-Best-Practises/blob/master/Umbraco.Extensions/Events/UmbracoEvents.cs#L44
Jeroen
Why is it inheriting from ApplicationEventHandler ?
An example: https://github.com/umbraco/Umbraco-CMS/blob/7.3.0/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs
Since you are NAMING your attribute you need to apply that in web.config:
You don't have to name your startup, see docs: http://www.asp.net/aspnet/overview/owin-and-katana/owin-startup-class-detection
Hello all,
I have a similar issue using Umbraco 7.3.4. I'm trying to use SignalR but I'm so far been unable to run the code in the Configuration method below. I've added a breakpoint on the base.Configuration(app) line but this never gets hit
I have remove the default and added the key to the web.config
Is there anything obvious that I could have missed which would mean my Configuration method would not run?
Is this still an issue for you? Your code/config looks fine and your Configuration should be hit
Hello Sharon,
Yes, this is still an issue for me. Fortunately, the requirement to use SignalR has been dropped, but I will need to get this going again in the near future.
I tinkered with things a bit... I tried a brand new Web Application in Visual Studio, and then installed Umbraco through NuGet (7.4.1 I think), and then SignalR, but I still couldn't get the breakpoint to be hit. If I installed SignalR straight into a Mvc application (not Umbraco), then the breakpoint would be hit. If the requirement to use SignalR had still existed, I was going to try to call app.MapSignalR from within an ActionFilter or an AuthorisationFilter (as I would have done in Mvc).
As you say my code looks fine (and I've repeated on another project), I suppose I could have missed something somewhere along the line.
Does a working version of an Umbraco Solution file with SignalR installed exist which I can download to test locally?
Thanks for your help Ben
Is this startup class in your App_Code or is it compiled?
hi Sharon,
It is compiled (Web Application).
same issue for me on 7.4.1 i want to use my own startup .. removing "owin:appStartup":"UmbracoDefaultOwinStartup" breaks the backoffice but my startup class is hit. adding it back in means my startup is never hit.
EDIT: worked it out. durrhhh. stupid me.
Create a Startup.cs and comment out "owin:appStartup":"UmbracoDefaultOwinStartup" , OWIN obviously looks for Startup by default. just need to inherit UmbracoDefaultOwinStartup
It's mostly because of the way you've declared your start-up class, you haven't named it in your Owin start-up attribute. What you've done will work but it's not best practices for Umbraco. You should use an overload on that attribute to give it a name and then use this name in your web config owin start-up declaration. Like this https://github.com/umbraco/UmbracoIdentityExtensions/blob/master/src/Umbraco.IdentityExtensions/App_Start/UmbracoStandardOwinStartup.cs.pp
http://nddt-webdevelopment.de/umbraco/umbraco-owinstartupattribute-friendlyname-error
This articles explains exact implementation details of integrating Owin in Umbraco 7
https://blog.indivirtual.nl/umbraco-7-3-and-oauth-2-0/
I had this issue, put a breakpoint in the code, never hit.
Spotted that in the app config the following owin startup was defined.
swapped it to
works perfectly now.
is working on a reply...