HttpRuntime Classe
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Fournit un ensemble de ASP.NET services d’exécution pour l’application actuelle.
public ref class HttpRuntime sealed
public sealed class HttpRuntime
type HttpRuntime = class
Public NotInheritable Class HttpRuntime
- Héritage
-
HttpRuntime
Exemples
L’exemple suivant montre comment obtenir les propriétés de la HttpRuntime classe représentant le domaine d’application actuel et les afficher dans le navigateur.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load(Object sender, System.EventArgs e)
{
StringBuilder sb = new StringBuilder();
String nl = "<br />";
sb.Append("AppDomainAppId = " +
HttpRuntime.AppDomainAppId + nl);
sb.Append("AppDomainAppPath = " +
HttpRuntime.AppDomainAppPath + nl);
sb.Append("AppDomainAppVirtualPath = " +
HttpRuntime.AppDomainAppVirtualPath + nl);
sb.Append("AppDomainId = " +
HttpRuntime.AppDomainId + nl);
sb.Append("AspInstallDirectory = " +
HttpRuntime.AspInstallDirectory + nl);
sb.Append("BinDirectory = " +
HttpRuntime.BinDirectory + nl);
sb.Append("ClrInstallDirectory = " +
HttpRuntime.ClrInstallDirectory + nl);
sb.Append("CodegenDir = " +
HttpRuntime.CodegenDir + nl);
sb.Append("IsOnUNCShare = " +
HttpRuntime.IsOnUNCShare.ToString() + nl);
sb.Append("MachineConfigurationDirectory = " +
HttpRuntime.MachineConfigurationDirectory + nl);
label1.Text = sb.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HttpRuntime Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:label id="label1" runat="server"/>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim sb As New StringBuilder()
Dim nl As String = "<br />"
sb.Append("AppDomainAppId = " & _
HttpRuntime.AppDomainAppId & nl)
sb.Append("AppDomainAppPath = " & _
HttpRuntime.AppDomainAppPath & nl)
sb.Append("AppDomainAppVirtualPath = " & _
HttpRuntime.AppDomainAppVirtualPath & nl)
sb.Append("AppDomainId = " & _
HttpRuntime.AppDomainId & nl)
sb.Append("AspInstallDirectory = " & _
HttpRuntime.AspInstallDirectory & nl)
sb.Append("BinDirectory = " & _
HttpRuntime.BinDirectory & nl)
sb.Append("ClrInstallDirectory = " & _
HttpRuntime.ClrInstallDirectory & nl)
sb.Append("CodegenDir = " & _
HttpRuntime.CodegenDir & nl)
sb.Append("IsOnUNCShare = " & _
HttpRuntime.IsOnUNCShare.ToString() & nl)
sb.Append("MachineConfigurationDirectory = " & _
HttpRuntime.MachineConfigurationDirectory & nl)
label1.Text = sb.ToString()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HttpRuntime Example</title>
</head>
<body>
<form id="Form1" runat="server">
<asp:label id="label1" runat="server"/>
</form>
</body>
</html>
Remarques
L’objet HttpRuntime est utilisé au début du modèle de pipeline ASP.NET qui traite les requêtes HTTP. La méthode ProcessRequest pilote tous les traitements web ASP.NET suivants.
Les développeurs de pages peuvent utiliser les HttpRuntime propriétés de classe pour obtenir des informations sur le domaine d’application actuel à des fins de diagnostic, par exemple. Les développeurs qui créent un pipeline de processus personnalisé ou un environnement d’hébergement personnalisé doivent appeler la ProcessRequest méthode à partir d’une classe dérivée de la ou SimpleWorkerRequest de la HttpWorkerRequest classe.
Constructeurs
| Nom | Description |
|---|---|
| HttpRuntime() |
Initialise une nouvelle instance de la classe HttpRuntime. |
Propriétés
| Nom | Description |
|---|---|
| AppDomainAppId |
Obtient l’identification de l’application du domaine d’application où il HttpRuntime existe. |
| AppDomainAppPath |
Obtient le chemin du lecteur physique du répertoire d’application pour l’application hébergée dans le domaine d’application actuel. |
| AppDomainAppVirtualPath |
Obtient le chemin d’accès virtuel du répertoire qui contient l’application hébergée dans le domaine d’application actuel. |
| AppDomainId |
Obtient l’identification de domaine du domaine d’application où existe l’instance HttpRuntime . |
| AspClientScriptPhysicalPath |
Obtient le chemin du dossier pour les fichiers de script client ASP.NET. |
| AspClientScriptVirtualPath |
Obtient le chemin d’accès virtuel pour les fichiers de script client ASP.NET. |
| AspInstallDirectory |
Obtient le chemin physique du répertoire dans lequel les fichiers exécutables ASP.NET sont installés. |
| BinDirectory |
Obtient le chemin d’accès physique au répertoire /bin de l’application active. |
| Cache |
Obtient l’application Cache actuelle. |
| ClrInstallDirectory |
Obtient le chemin d’accès physique au répertoire où les fichiers exécutables common language runtime sont installés. |
| CodegenDir |
Obtient le chemin d’accès physique au répertoire où ASP.NET stocke des fichiers temporaires (sources générées, assemblys compilés, et ainsi de suite) pour l’application actuelle. |
| IISVersion |
Obtient la version d’IIS qui héberge cette application. |
| IsOnUNCShare |
Obtient une valeur qui indique si l’application est mappée à un partage UNC (Universal Naming Convention). |
| MachineConfigurationDirectory |
Obtient le chemin d’accès physique au répertoire où se trouve le fichier Machine.config de l’application actuelle. |
| TargetFramework |
Obtient la version du .NET Framework cible par l’application web actuelle. |
| UsingIntegratedPipeline |
Obtient une valeur qui indique si l’application actuelle s’exécute en mode de pipeline intégré d’IIS 7.0. |
| WebObjectActivator |
Obtient ou définit l’instance pour la prise en charge de l’injection IServiceProvider de dépendances. |
Méthodes
| Nom | Description |
|---|---|
| Close() |
Arrête l’instance HttpRuntime . |
| Equals(Object) |
Détermine si l’objet spécifié est égal à l’objet actuel. (Hérité de Object) |
| GetHashCode() |
Sert de fonction de hachage par défaut. (Hérité de Object) |
| GetNamedPermissionSet() |
Retourne l’ensemble d’autorisations associées aux groupes de codes. |
| GetType() |
Obtient la Type de l’instance actuelle. (Hérité de Object) |
| MemberwiseClone() |
Crée une copie superficielle du Objectactuel. (Hérité de Object) |
| ProcessRequest(HttpWorkerRequest) |
Pilote toutes les ASP.NET l’exécution du traitement web. |
| ToString() |
Retourne une chaîne qui représente l’objet actuel. (Hérité de Object) |
| UnloadAppDomain() |
Termine l’application actuelle. L’application redémarre la prochaine fois qu’une demande est reçue pour celle-ci. |