Is This Correct

K

Keith Chadwick

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top