#927 - Un HttpModule per passare automaticamente da HTTP a HTTPS
sgabbu73 non è online. Ultima attività: 17/08/2008 21.20.56sgabbu73
Inserito il: 24 gennaio 2008 09.48
24 messaggi dal 15 gen 2007 Istalla Microsoft Silverlight!
Trovo molto utile questo script, soprattutto per la mia applicazione web, ma sarebbe possibile avere anche la versione in VB???
Microsoft Most Valuable Professional
Re: #927 - Un HttpModule per passare automaticamente da HTTP a HTTPS
SM15455 non è online. Ultima attività: 04/09/2008 15.13.23SM15455
Inserito il: 24 gennaio 2008 09.59
contributi / Top Poster / Community manager / Blog / 2560 messaggi dal 06 set 2002 Istalla Microsoft Silverlight!
Ciao,

ti segnalo questo ottimo traduttore da C# a vb.net e viceversa:
http://www.carlosag.net/Tools/CodeTranslator/Default.aspx

HTH
.

Nothing can be born from hartred

Stefano (SM15455) Mostarda
http://blogs.aspitalia.com/SM15455
Rome Italy
Re: #927 - Un HttpModule per passare automaticamente da HTTP a HTTPS
sgabbu73 non è online. Ultima attività: 17/08/2008 21.20.56sgabbu73
Inserito il: 25 gennaio 2008 09.29
24 messaggi dal 15 gen 2007 Istalla Microsoft Silverlight!
Ho provato ad utilizzarlo (in effetti lo conoscevo già) e ho raggiunto questo risultato:

Public Class HttpToHttpsModule

Implements IHttpModule

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


Private Sub context_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
If Not HttpContext.Current.Request.IsSecureConnection Then
Dim pages As ProtectedPagesSection = CType(ConfigurationManager.GetSection("protectedPagesSection"), ProtectedPagesSection)
For Each elem As NameValueConfigurationElement In pages.Pages
Dim lt As System.Web.UI.WebControls.Literal = New Literal
If (String.Compare(HttpContext.Current.Request.Url.LocalPath, lt.ResolveUrl(elem.Value), StringComparison.OrdinalIgnoreCase) = 0) Then
HttpContext.Current.Response.Redirect(HttpContext.Current.Request.Url.ToString.Replace("http", "https"))
End If
Next
End If
End Sub

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

End Sub

End Class

Public Class ProtectedPagesSection
Inherits ConfigurationSection

<ConfigurationProperty("Pages", IsDefaultCollection:=True)> _
Public ReadOnly Property Pages() As NameValueConfigurationCollection
Get
Return CType(MyBase.Item("Pages"), NameValueConfigurationCollection)
End Get
End Property
End Class

e non ho nessun errore nella compilazione...

però in corrispondenza di questa rige nel web.config:

<add name="HttpToHttps" type="HttpToHttpsModule" />

mi ritorna questo errore:

"Impossibile caricare il tipo 'HttpToHttpsModule'."

(
P.S. ho inserito anche questa parte:

<configSections>
<section name="protectedPagesSection" type="ProtectedPagesSection" />
</configSections>

<protectedPagesSection>
<Pages>
<add name="Page1" value="~/Login.aspx" />
</Pages>
</protectedPagesSection>
)

dove sbaglio????

grazie in anticipo!

Gabriele.

Vai a:
Torna al forum |   Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.


maltra - 701 pt
vladimiro - 471 pt
fabrica - 180 pt

Ultimi vincitori: fabrica, vladimiro, PeppeDotNet

Iscriviti anche tu e raccogli punti. Questo mese in palio VS 2008 + Windows Server 2008, ReShaper e 1 ebook!



COMMUNITY
ULTIMI MESSAGGI


IN EVIDENZA
MISC
Powered by .db Forums