Master page e httpmodule

martedì 03 marzo 2009 - 09.50

geppos1975 Profilo | Newbie

Ciao a tutti.
Vorrei cambiare dinamicamente la masterpage del mio sito.
Gia utilizzo Ihttpmdule per cambiare dinamicamente il tema della pagina senza dover riscrivere la preinit di ogni pagina.
Lo stesso procedimento però non mi funziona con la masterpage.

Il codice che ho scritto è il seguente:

Public Class ProvaHttp
Implements IHttpModule

Public Sub New()
' Costruttore
End Sub

Public Sub Dispose() Implements System.Web.IHttpModule.Dispose

End Sub

Public Sub Init(ByVal context As System.Web.HttpApplication) Implements System.Web.IHttpModule.Init
AddHandler context.PreRequestHandlerExecute, AddressOf PreRequestHandlerExecute
End Sub

Protected Sub PreRequestHandlerExecute(ByVal sender As Object, ByVal e As EventArgs)
Dim CurrentContext As HttpContext = HttpContext.Current
If (Not TypeOf CurrentContext.Handler Is Page) Then Return
Dim myPage As Page = CurrentContext.Handler

' verifico se la pagina ha definita una master page
If myPage.MasterPageFile = Nothing Then
Else
myPage.MasterPageFile = CurrentContext.Session.Item("MasterPage")
End If
myPage.Theme = CurrentContext.Session.Item("Tema")
End Sub
End Class

Qualcuno mi puoi aiutare?

Grazie
Giuseppe
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5