Modify Httpcontext.Current.User is breaking the Bundle Optimization

Asked

Viewed 65 times

2

I did several tests and I could see that by modifying the HttpContext.Current.User Application_PostAuthenticateRequest (Global.asax.Cs) I get an Internal Server Error in the concatenated/minified Bundle request.

Follows code quoted:

protected void Application_PostAuthenticateRequest( Object sender, EventArgs e )
    {
        HttpContext.Current.User = SessionManager.GetCurrentUser( Request );

        if (IsWebApiRequest())
        {
            HttpContext.Current.SetSessionStateBehavior( SessionStateBehavior.Required );
        }
    }

    private bool IsWebApiRequest()
    {
        return HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath.StartsWith( WebApiConfig.UrlPrefixRelative );
    }

inserir a descrição da imagem aqui

  • There is only the header of the request with error. What is the real error?

  • The request does not generate an Http Response in the console. It generates an html with an Runtime error. https://gist.github.com/cbfranca/5b32461f6613486e3d11

  • A kick: I think for Bundling there is no user associated with the context. Have you tried debugging this event?

  • 1

    That’s exactly what @Ciganomorrisonmendez. Obg

1 answer

2


The problem was that the SessionManager.GetCurrentUser( Request ); this null and when assigning to HttpContext.Current.User Bundle generated an exception.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.