Click here to Skip to main content
15,886,806 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Search is slow if large data in Gridview Pin
ashjassi17-Aug-12 2:59
ashjassi17-Aug-12 2:59 
Questionupload MS Word to MySQL Pin
Jassim Rahma16-Jul-12 7:46
Jassim Rahma16-Jul-12 7:46 
AnswerRe: upload MS Word to MySQL Pin
Sandeep Mewara16-Jul-12 21:07
mveSandeep Mewara16-Jul-12 21:07 
QuestionSession time out not working Pin
Member 910478815-Jul-12 23:00
Member 910478815-Jul-12 23:00 
AnswerRe: Session time out not working Pin
Karthik Harve15-Jul-12 23:09
professionalKarthik Harve15-Jul-12 23:09 
AnswerRe: Session time out not working Pin
Rahul Rajat Singh16-Jul-12 2:18
professionalRahul Rajat Singh16-Jul-12 2:18 
AnswerRe: Session time out not working Pin
Karthik Harve16-Jul-12 2:31
professionalKarthik Harve16-Jul-12 2:31 
QuestionASPNET putting business classes in session ? Pin
billymac105915-Jul-12 15:31
billymac105915-Jul-12 15:31 
My ASP.net application uses a common class I added to my App_Code folder which has all of the methods I use more than once throughout the application.

Because this class is used in the masterpage, almost all site aspx pages and multiple usercontrols, I am instantiating the class multiple times in each request.
I am instantiating the class in the page_load of pages and controls and then setting it to nothing on each page_unload.
There is nothing in the class that needs to maintain state between requests.

Is there a better way to do this or is that the normal approach?
It seems so inefficient to me to be creating/destroying the class in every code behind file.

I was wondering if there would be any advantage to putting the class in each users session for re-use for the lifetime of the session.
I don't know if there would be any advantage to that approach or not.
i was thinking of checking (each time I instantiate) if the object is in session and if not add it and if its already in session, return the object.
I guess I could do that in the objects constructor.


Any suggestions much appreciated
Heres what I am doing in every code behind file now:


Dim c As New CommonCode()

    Public ReadOnly Property C As CommonCode
        Get
            If C Is Nothing Then C = New CommonCode
            Return C
        End Get
    End Property


Protected Sub btnPostComment_Click(sender As Object, e As EventArgs)

  Dim name As String = IIf(txtName.Text = [String].Empty, "Anonymous", txtName.Text)
        If txtComments.Text <> [String].Empty Then
            c.PostComment(ID, name, txtComments.Text, RadRating.Value)
        End If
    End Sub

Protected Sub Page_Unload(sender As Object, e As System.EventArgs) Handles Me.Unload
        c = Nothing
    End Sub

AnswerRe: ASPNET putting business classes in session ? Pin
Rahul Rajat Singh16-Jul-12 2:27
professionalRahul Rajat Singh16-Jul-12 2:27 
QuestionDevExpress Grid Pin
basitsar14-Jul-12 4:56
basitsar14-Jul-12 4:56 
AnswerRe: DevExpress Grid Pin
Sandeep Mewara14-Jul-12 21:50
mveSandeep Mewara14-Jul-12 21:50 
QuestionValidation Expression Question Pin
Jassim Rahma14-Jul-12 1:45
Jassim Rahma14-Jul-12 1:45 
AnswerRe: Validation Expression Question Pin
Sandeep Mewara14-Jul-12 21:52
mveSandeep Mewara14-Jul-12 21:52 
GeneralSEND MAIL Pin
laxman sindh13-Jul-12 20:21
laxman sindh13-Jul-12 20:21 
GeneralRe: SEND MAIL Pin
Richard MacCutchan13-Jul-12 22:51
mveRichard MacCutchan13-Jul-12 22:51 
AnswerRe: SEND MAIL Pin
Sandeep Mewara14-Jul-12 22:01
mveSandeep Mewara14-Jul-12 22:01 
GeneralRe: SEND MAIL Pin
wikizhao15-Jul-12 16:25
wikizhao15-Jul-12 16:25 
AnswerRe: SEND MAIL Pin
Dhyanga17-Jul-12 10:32
Dhyanga17-Jul-12 10:32 
QuestionDevelop Enterpise Applicattions with ASP.NET Pin
Phatinox13-Jul-12 2:08
Phatinox13-Jul-12 2:08 
AnswerRe: Develop Enterpise Applicattions with ASP.NET Pin
David Mujica13-Jul-12 2:27
David Mujica13-Jul-12 2:27 
AnswerRe: Develop Enterpise Applicattions with ASP.NET Pin
Member 771364713-Jul-12 2:54
Member 771364713-Jul-12 2:54 
GeneralRe: Develop Enterpise Applicattions with ASP.NET Pin
Phatinox13-Jul-12 3:10
Phatinox13-Jul-12 3:10 
AnswerRe: Develop Enterpise Applicattions with ASP.NET Pin
wikizhao15-Jul-12 16:29
wikizhao15-Jul-12 16:29 
Questioncannot convert dataview t0 dataset Pin
sumeet kumar Attri12-Jul-12 21:13
sumeet kumar Attri12-Jul-12 21:13 
AnswerRe: cannot convert dataview t0 dataset Pin
Sandeep Mewara12-Jul-12 23:04
mveSandeep Mewara12-Jul-12 23:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.