Is This Correct

Discussion in 'ASP .Net' started by Keith Chadwick, Nov 5, 2003.

  1. I am migrating an existing ASP application over to .NET as a learning exercise. The existing application uses a lot of xsl and xml transformations to render each page. Stored as an application variable is an xml set that contains all the language strings for the web site. Each page contains a 3 transformations. The first being the navigation bar, second the body for the current page and lastly the footer transformation. The header and footer xsl files are also stored as application variables as they are used on every page. The body xsl file is loaded per page. Each xsl file is rendered against the xml language set and placed on the current page.

    So in moving this to the .NET I want to do a similar implementation. Within the global.asax file I am loading the header and footer pages in the application cache as thus:
    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)

    '----------------------------------------------------------------
    ' Assign Database Connection String
    '----------------------------------------------------------------
    Context.Cache("dbCnctstr")="Server=myserver;UID=me;PWD=pwd;database=db"

    '----------------------------------------------------------------
    ' Load the header and footer xsl files to application
    '----------------------------------------------------------------
    Dim xslNAVBAR As New MSXML2.DOMDocument30()
    xslNAVBAR.load(Server.MapPath("Admin/XSL/clnt.navbar.xsl"))
    Context.Cache("xslNAVBAR") = xslNAVBAR
    Dim xslFOOTER As New MSXML2.DOMDocument30()
    xslFOOTER.load(Server.MapPath("Admin/XSL/clnt.footer.xsl"))
    Context.Cache("xslFOOTER") = xslFOOTER

    End Sub

    Am I correct in assuming that the above xsl document objects are being placed in the application 'CACHE'? I have been informed to use the application cache because it is thread safe. Now within a ASPX page can I reference either of these objects with Context.Cache("name")?

    The language xml set is a little more difficult. I am trying to create a public class that handles the load of the data and subsequent methods I will need later on. Basically trying to replicate several functions I had in ASP into a logical class. My class is entitled Language within the AllianceNet application and does not inherit or import anything. One of the methods I have is entitled LoadLanguage, as seen below:

    Public Class Language
    Public Function LoadLanguage(ByVal AssignCache as Boolean)
    ' create database connection
    ' Enumerate xml auto recordset

    Dim xmlLANG as New MSXML2.DOMDocument30()
    ' Load xml data from sql server auto xml recordset into xmlLANG object

    if AssignCache Then
    System.Web.HttpContext.Current.Cache("xmlLANG")=myxmlLangObj
    end if
    return
    End Class

    Now in the Application_Start() routine in the global.asax I have added.

    Dim clsLang As New allianceNet.Language()
    clsLang.LoadLanguage(True)

    Another reason I need to separate out the load of the language XML is that there are times I need to reload the xmlLANG data on cue from a ASPX page.

    So basically what I am asking is am I on the right track. I do find it the application level scope fairly confusing as there seems to be contradictory information between the books I have and the information I receive via other mediums.

    Any feedback would be appreciated.

    Cheers

    Keith
    Keith Chadwick, Nov 5, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tim Hubberstey
    Replies:
    0
    Views:
    1,067
    Tim Hubberstey
    Jul 3, 2003
  2. joon
    Replies:
    1
    Views:
    515
    Roedy Green
    Jul 8, 2003
  3. Dan

    correct or not correct?

    Dan, Oct 2, 2003, in forum: HTML
    Replies:
    7
    Views:
    441
  4. J.Ram
    Replies:
    7
    Views:
    651
  5. froil
    Replies:
    12
    Views:
    310
    Gunnar Hjalmarsson
    Mar 2, 2006
Loading...

Share This Page