1.5.1 - Module route not working (the first time)

Topics: Troubleshooting
Aug 27, 2012 at 7:51 PM

Created a module which exposes a route to allow us to use single sign on with a token. If I open the browser, paste the url it doesn't work. I get the access denied page. If i paste it again, now it works. It will not work for the first request. I have tried high and low priorities and nothing seems to make a difference.

URL:

http://localhost:9889/SSO/{99BB976E-BCB6-483F-8B53-0FFB247EF9F5}/Login

Route Code:

public IEnumerable<RouteDescriptor> GetRoutes()
{
    return new[] 
    {
        new RouteDescriptor 
        {
            Priority = 15,
            Route = new Route
            (
                "SSO/{token}/Login",
                new RouteValueDictionary 
                {
                    {"area", "Maximizedliving.WebsiteSSO"},
                    {"controller", "SSO"},
                    {"action", "Login"}
                },
                new RouteValueDictionary(),
                new RouteValueDictionary 
                {
                    {"area", "Maximizedliving.WebsiteSSO"}
                },
                new MvcRouteHandler()
            )
        }
    };
}

Thank you,
Chris 

Coordinator
Aug 28, 2012 at 4:35 AM

That's very likely a caching issue, but just in case, please check app_data\logs for errors corresponding to the time of your first request.

Aug 28, 2012 at 2:09 PM

Thank you for the reply. There was in fact an error. There was another module that writes meta tags that was attempting to access work context which was null. Adding a null check around the code led to this in the error debug log:

2012-08-28 09:02:47,461 [9] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:47,508 [9] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:47,539 [9] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505

at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17 2012-08-28 09:02:48,189 [22] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler System.NullReferenceException: Object reference not set to an instance of an object. at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500 at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30 at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333 at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:48,259 [22] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:48,359 [22] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:48,399 [23] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:48,419 [17] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:48,419 [19] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:48,419 [20] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:48,439 [21] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:48,469 [23] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:48,489 [17] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:48,489 [20] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:48,489 [19] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:48,514 [23] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:48,514 [17] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:48,514 [21] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:48,514 [20] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:48,530 [19] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:48,561 [21] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:49,015 [12] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:49,075 [12] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17
2012-08-28 09:02:49,091 [12] Orchard.ContentManagement.DefaultContentManager - NullReferenceException thrown from IContentHandler by Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler
System.NullReferenceException: Object reference not set to an instance of an object.
   at Orchard.ContentManagement.DefaultContentManager.GetItemMetadata(IContent content) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 500
   at Orchard.Core.Navigation.Handlers.ContentMenuItemPartHandler.GetItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard.Web\Core\Navigation\Handlers\ContentMenuItemPartHandler.cs:line 30
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 333
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass60.b__5f(IContentHandler handler) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 505
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\TFS\Application\Orchard\Release1.5\src\Orchard\InvokeExtensions.cs:line 17

Aug 28, 2012 at 2:52 PM

I should probably mention that yes, I am in the process of debugging that method but didn't want to go too long without responding ;)

Aug 29, 2012 at 12:53 PM

Spent a little time debugging the above errors and decided to eliminate everything first. Did a clean orchard 1.5.1 install and only activated my SSO module. There are no longer any errors in the log file but the original problem remains. The SSOController Login method never gets hit. for the first request.  I have pasted a simplified version with no encryption and only pass the username as the token. This is the same code I am using to troubleshoot. Now I am looking at how routing works.

Url:

http://localhost:9889/SSO/root/Login

Routes.cs

using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Routing;
using Orchard.Mvc.Routes;

namespace Maximizedliving.WebsiteSSO
{
    public class Routes : IRouteProvider
    {
        public void GetRoutes(ICollection<RouteDescriptor> routes)
        {
            foreach (var routeDescriptor in GetRoutes())
                routes.Add(routeDescriptor);
        }

        public IEnumerable<RouteDescriptor> GetRoutes()
        {
            return new[] 
            {
                new RouteDescriptor 
                {
                    Priority = 15,
                    Route = new Route
                    (
                        "SSO/{token}/Login",
                        new RouteValueDictionary 
                        {
                            {"area", "Maximizedliving.WebsiteSSO"},
                            {"controller", "SSO"},
                            {"action", "Login"}
                        },
                        new RouteValueDictionary(),
                        new RouteValueDictionary 
                        {
                            {"area", "Maximizedliving.WebsiteSSO"}
                        },
                        new MvcRouteHandler()
                    )
                }
            };
        }
    }
}
SSOController.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Maximizedliving.WebsiteSSO.Services;
using Orchard.Security;

namespace Maximizedliving.WebsiteSSO.Controllers
{
    public class SSOController : Controller
    {
        readonly IAuthenticationService _authenticationService;
        readonly IMembershipService _membershipService;
        readonly ICryptoService _cryptoService;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="authenticationService"></param>
        /// <param name="membershipService"></param>
        /// <param name="cryptoService"></param>
        public SSOController(IAuthenticationService authenticationService, IMembershipService membershipService, ICryptoService cryptoService)
        {
            _authenticationService = authenticationService;
            _membershipService = membershipService;
            _cryptoService = cryptoService;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        public ActionResult Login(string token)
        {
            var currentUser = _authenticationService.GetAuthenticatedUser();
            if (currentUser == null)
            {
                TryLoginUser(token);
            }
            return new RedirectResult("~/Admin/");
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        bool TryLoginUser(string username)
        {
            var user = _membershipService.GetUser(username);

            if (user != null)
            {
                _authenticationService.SignIn(user, false);
                return true;
            }
            return false;
        }
    }
}
Aug 29, 2012 at 5:40 PM

Not really sure what is going on. Clean install, only sso module is active and I made a request to http://localhost:9990/SSO/root/Login using composer in fiddler. I am not sure why it is redirecting. I tried removing the RedirectResult from the controller just in case it was actually hitting but not breaking for some reason. Still get the following:

GET http://localhost:9990/SSO/root/Login HTTP/1.1
User-Agent: Fiddler
Host: localhost:9990

HTTP/1.1 302 Found
Location: /Users/Account/AccessDenied?ReturnUrl=%2fSSO%2froot%2fLogin
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Wed, 29 Aug 2012 16:06:53 GMT
Content-Length: 176

Object moved

Object moved to here.

Aug 31, 2012 at 1:01 PM

Created a new MVC3 app using the VS2010 template. Added SSOController and a route. F5, detached, closed the browser, opened a new browser, pasted the url and it hit the controller method like it's supposed to. Hosted the same app in IIS and it didn't work until I had: Anonymous Access: enabled, Forms Authentication: enabled, Basic Authentication: disabled, Windows Authentication: disabled. Made sure IIS for Orchard was setup the same way and I can't get it to work. Debug jumps straight from ThemeFilter.cs Apply() to the controller AccessDenied and call stack only shows [External Code]. I got rid of the token for now so I am only dealing with SSO/Login. I have tried adding the following to the Orchard web.config:

  <location path="~/SSO/Login">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>

I have also tried creating an SSO folder and dropping a web.config in there with location set.  Am I overlooking something very simple here?


Developer
Sep 13, 2012 at 5:09 AM

Are you sure you tested with a token for which a user actually exists? What happens if you temporarily change the implementation of TryLoginUser to always create an authentication ticket?

Sep 13, 2012 at 9:09 AM

Thanks for the reply. For testing I got rid of the token entirely and just passed the username root which is our admin user. It never hits the TryLoginUser on the first request. It never hits the controller method period until the 2nd request. After the first request, it says access denied and redirects to the login page. I don't log in. I paste the url again into the address bar and press enter and it works just like its supposed to. It's something about the initial request that isn't working.