Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Application_Start() but only for Web Service
Message
De
28/01/2015 11:12:50
 
 
À
28/01/2015 10:46:36
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01614485
Message ID:
01614491
Vues:
13
>My Global.asax file is containing only one line which forwards to my framework Global class the role to set up everything. The Global.asax, either for the Web or for the Web Service, will call the Global class. This contains code that is subject to IIS, the application pool and so on. Today, I added the Application_Start() event to load something. But, I only need to load that when I am from a Web Service environment.
>
>Here is a brief look at the main sections for the code of the Global class:
>
>
>Imports System.Web
>Imports System.Reflection
>
>Public Class GlobalBase
>    Inherits System.Web.HttpApplication
>
>    Private oApp As App = Nothing
>
>    Sub Application_PreRequestHandlerExecute(ByVal sender As Object, ByVal e As EventArgs)
>    End Sub
>
>    Sub Application_Start()
>        RegisterSoapExtension(GetType(TraceExtension), 1, 0)
>    End Sub
>
>    Sub Application_End()
>    End Sub
>
>    <System.Security.Permissions.ReflectionPermission(System.Security.Permissions.SecurityAction.Demand, Unrestricted:=True)> _
>    Public Shared Sub RegisterSoapExtension(type As Type, priority As Integer, group As System.Web.Services.Configuration.PriorityGroup)
>    End Sub
>
>End Class
>
>
>How can I make sure the Application_Start() will only execute RegisterSoapExtension() when I am running under a Web Service? Because I assume this will conflict if being run under a Web site or will be useless.
>
>We are running under the System.Web.HttpApplication class. Is there something in there letting us about that?

Application_Start fires then the first request hits the server (or, IIRC, when the pool recycles). Registering the extension in code there is the equivalent of doing it via web.config. Maybe it will never be used - but that's not a problem.......
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform