This is a migrated thread and some comments may be shown as answers.

Error in Website while opening my connection

2 Answers 87 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Bernd
Top achievements
Rank 2
Bernd asked on 26 Jun 2013, 06:44 AM
Hello all.
I use the recommended way to manage the OpenAccess context. In Visual Studio it works fine. Deploying it I get this ugly message:

Event handlers can only be bound to HttpApplication events during IHttpModule initialization

"<validation validateIntegratedModeConfiguration="false" />" is set in web.config as suggested here.

I don't think it has to do with ORM, but I hope someone here can give me a hint where to look.

Thanks in advance
Bernd

My code to manage the context:
public class ContextFactory
{
    public static DispatcherEntities GetContextPerRequest()
    {
        HttpContext httpContext = HttpContext.Current;
        if (httpContext == null)
            return new DispatcherEntities();
        else
        {
            httpContext.ApplicationInstance.EndRequest += new System.EventHandler(ContextFactory.ApplicationInstance_EndRequest);
            int contextID = Thread.CurrentContext.ContextID;
            int hashCode = httpContext.GetHashCode();
            string key = string.Concat(hashCode, contextID);
            DispatcherEntities context = httpContext.Items[key] as DispatcherEntities;
            if (context == null)
            {
                context = new DispatcherEntities();
                httpContext.Items[key] = context;
            }
            return context;
        }
    }
 
    private static void ApplicationInstance_EndRequest(object sender, EventArgs e)
    {
        DispatcherEntities context = ContextFactory.GetContextPerRequest();
        if (context != null)
        {
            context.Dispose();
        }
    }
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar Tachev
Telerik team
answered on 28 Jun 2013, 04:08 PM
Hi Bernd,

 
I suppose that this error is caused by a different version of the IIS on your server compared with the one on your local machine.

Discussing some possible issues like the one that you have described we decided to remove the HTTPModule approach from our recommended ones.

In order to make sure that you will not have any further issues managing your OpenAccessContext I suggest you choose one of our actual recommended approaches described in this documentation section. I believe that the one which is using the HttpContext will be most similar to the one that you have already implemented.

I hope this is applicable for you. Do not hesitate to contact us back if you need any further assistance.

Regards,
Dimitar Tachev
Telerik
OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvementsshipped with this release.

0
Bernd
Top achievements
Rank 2
answered on 29 Jun 2013, 10:04 PM
Hi Dimitar.

This solved my problem. Thanks for your support.
Bernd
Tags
Data Access Free Edition
Asked by
Bernd
Top achievements
Rank 2
Answers by
Dimitar Tachev
Telerik team
Bernd
Top achievements
Rank 2
Share this question
or