Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Moving from web.config to HttpApplication
Message
De
28/01/2015 09:46:55
 
 
À
28/01/2015 09:36:04
Information générale
Forum:
ASP.NET
Catégorie:
Web Services
Versions des environnements
Environment:
VB 9.0
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01614430
Message ID:
01614474
Vues:
21
This message has been marked as a message which has helped to the initial question of the thread.
>>No idea if this works but : http://www.justskins.com/forums/programatically-register-soapextensions-77036.html
>>But why do you want to do this?
>
>I have added the following in my Global class:
>
>
>    Private Shared Sub InjectTraceExtensionToConfig()
>        Dim assBase As Assembly
>        Dim webServiceConfig As Type
>        Dim currentProp As Object
>        Dim propInfo As PropertyInfo
>        Dim value As Object()
>        Dim myType As Type
>        Dim objArray As Object()
>        Dim myObj As Object
>        Dim myField As FieldInfo
>
>        Try
>            assBase = GetType(System.Web.Services.Protocols.SoapExtensionAttribute).Assembly
>            webServiceConfig = assBase.[GetType]("System.Web.Services.Configuration.WebServicesCon figuration")
>
>            If webServiceConfig Is Nothing Then
>                Throw New Exception("Error ...")
>            End If
>
>            currentProp = webServiceConfig.GetProperty("Current").GetValue(Nothing, Nothing)
>            propInfo = webServiceConfig.GetProperty("SoapExtensionTypes")
>            value = DirectCast(propInfo.GetValue(currentProp, Nothing), Object())
>            myType = value.[GetType]().GetElementType()
>            objArray = DirectCast(Array.CreateInstance(myType, CInt(value.Length) + 1), Object())
>            Array.Copy(value, objArray, CInt(value.Length))
>
>            myObj = Activator.CreateInstance(myType)
>            myField = myType.GetField("Type")
>            myField.SetValue(myObj, GetType(TraceExtension))
>            objArray(CInt(objArray.Length) - 1) = myObj
>            propInfo.SetValue(currentProp, objArray, Nothing)
>        Catch ex As Exception
>        End Try
>    End Sub
>
>
>The Global class is called from Global.asax:
>
>
>< @ Application Language="VB" Inherits="Framework.GlobalBase"%>
>
>
>But, as is, it will not do anything. Something has to trigger this method. This is where I am not sure about the proper way to establish a trigger here. When this is in the web.config. the trigger is done by .NET. But, in the code, there is a missing link here.

Maybe Application_Start() ?

>The reason I want to put this in the code is to have the control over it. Everything that most of the people usually put in Global.asax, I put it in my Global class. Then, from Global.asax, the only thing I have to put is the one line you see above. By that, I do not have to worry about setting up web.config wherever I need a Web site or Web service application. I control everything from the framework and that makes it easier to migrate to another development environment when time comes. This Global.asax is to proprietary to .NET.

Fair enough - but you could probably use the machine.config or the root web.config to do that.....
I'd favour web.config because you can change settings on the fly without re-publishing, use hierarchies, build different web.configs for release/debug versions etc. etc....
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform