Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kevin Jump 1867 posts 11859 karma points MVP 4x c-trib
    Feb 28, 2013 @ 22:39
    Kevin Jump
    0

    6.0.1 MediaType.Save fails if called at application startup

    I have a package that reads in settings and saves them at application startup time. ( http://our.umbraco.org/projects/developer-tools/usync)  it is hooked into IApplicationEventHandler OnStarted function. 

    One thing is does is loads and saves MediaTypes 

    on 4.11.x (including 4.11.5) and 6.0.0 this works. on 6.0.1 it throws the following error

     

    [HttpException (0x80004005): Request is not available in this context]
       System.Web.HttpContext.get_Request() +9718164
       System.Web.HttpContextWrapper.get_Request() +28
       umbraco.BusinessLogic.Cookies.get_HasCookies() +26
       umbraco.BasePages.BasePage.get_umbracoUserContextID() +25
       umbraco.BusinessLogic.User.GetCurrent() +8
       umbraco.cms.businesslogic.media.MediaType.Save() +269

     

    looking at the source the following lines have been added to MediaType.Save

     

    var current = User.GetCurrent()    ;
    int userId = current == null ? 0 : current.Id;
    ApplicationContext.Current.Services.ContentTypeService.Save(_mediaType, userId);
    I suspect they are causing this error

     

    is this a bug ? or my stupid coding ? 

     

     

  • Kevin Jump 1867 posts 11859 karma points MVP 4x c-trib
    Feb 28, 2013 @ 22:57
    Kevin Jump
    0

    It all works if i switch from using IApplicationEventHandler and go back to ApplicationBase. 

    given that IApplicationEventHandler is implimented diffrently in 4.11.x and 6.x shall i admit defeat and go back to the Deprecated ApplicationBase method ? 

  • Kevin Jump 1867 posts 11859 karma points MVP 4x c-trib
    Mar 04, 2013 @ 20:50
    Kevin Jump
    0

    I''ve logged this as a bug, because it does happen on ApplicationBase also,  http://issues.umbraco.org/issue/U4-1831

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies