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

Handling Context in ASP.net page

4 Answers 44 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jdorak
Top achievements
Rank 2
Jdorak asked on 14 Nov 2011, 10:06 PM
I was reading thru the OpenAccess documentation and found 2 ways of dealing with the context in ASP.Net.

1) Using Master Pages (easier to implement)
2) Using HttpModule (by far more complicated and I could not even get it working as per Telerik examples online)


Master Pages way is super easy to implement however what happens if I do not use Master pages? So I tried on a regular .aspx page to override both the OnInit  and Dispose methods and created a private variable to hold the context (pretty much the exact same way as what goes in the code of the Master Page approach).

As follows:

        private WebContext context;

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.context = new WebContext();
        }

        public override void Dispose()
        {
            base.Dispose();
            this.context.Dispose();
        }


So this works just as good as using the Master Page approach. However since Telerik does not mentions this approach I was wondering maybe something really wrong is going to happen down the line. Or maybe I am being too paranoid. Anyone could let me know if this 3rd approach is a big NO-NO? Or if is just as ok as the Master Page approach? If so then why would someone in their right mind even consider the HttpModule approach (I could not even get it working on my end).

4 Answers, 1 is accepted

Sort by
0
Accepted
Damyan Bogoev
Telerik team
answered on 15 Nov 2011, 03:37 PM
Hi Rtelles,

You could use this approach for a single page as well not only with Master page.
Another approach which you could use for handling the context can be found in this KB article.
Hope that helps.

Greetings,
Damyan Bogoev
the Telerik team

NEW and UPDATED OpenAccess ORM Resources. Check them out!

0
Jdorak
Top achievements
Rank 2
answered on 15 Nov 2011, 04:40 PM
Thanks for the reply Damyan. Now I feel more at ease just using the context that way. I like a lot the way is shown in that article and will use it for the situations were I have multiple user controls on a page. It looks like a very straight forward way. Seems to me with these two options there is no need for the HttpModule approach.
0
Jdorak
Top achievements
Rank 2
answered on 15 Nov 2011, 04:40 PM
(Double Post) It seems the Telerik forums are experiencing issues lately. I am getting a lot of error pages.
0
Ivailo
Telerik team
answered on 18 Nov 2011, 01:39 PM
Hello Rafael,

Thanks for notifying us about your issues with the forum - we will check for possible problems. Do not hesitate to inform us if it appears again.


Regards,

Ivailo
the Telerik team

NEW and UPDATED OpenAccess ORM Resources. Check them out!

Tags
General Discussions
Asked by
Jdorak
Top achievements
Rank 2
Answers by
Damyan Bogoev
Telerik team
Jdorak
Top achievements
Rank 2
Ivailo
Telerik team
Share this question
or