2 // HttpContextWrapper.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2008-2010 Novell Inc. http://novell.com
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Collections;
32 using System.Collections.Generic;
33 using System.Globalization;
34 using System.Runtime.CompilerServices;
35 using System.Security.Permissions;
36 using System.Security.Principal;
37 using System.Web.Caching;
38 using System.Web.Profile;
39 using System.Web.SessionState;
44 [TypeForwardedFrom ("System.Web.Abstractions, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
46 [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
47 [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
48 public class HttpContextWrapper : HttpContextBase
52 public HttpContextWrapper (HttpContext httpContext)
54 if (httpContext == null)
55 throw new ArgumentNullException ("httpContext");
59 public override Exception [] AllErrors {
60 get { return w.AllErrors; }
63 public override HttpApplicationStateBase Application {
64 get { return new HttpApplicationStateWrapper (w.Application); }
67 public override HttpApplication ApplicationInstance {
68 get { return w.ApplicationInstance; }
69 set { w.ApplicationInstance = value; }
72 public override Cache Cache {
73 get { return w.Cache; }
76 public override IHttpHandler CurrentHandler {
77 get { return w.CurrentHandler; }
80 public override RequestNotification CurrentNotification {
81 get { return w.CurrentNotification; }
84 public override Exception Error {
85 get { return w.Error; }
88 public override IHttpHandler Handler {
89 get { return w.Handler; }
90 set { w.Handler = value; }
93 public override bool IsCustomErrorEnabled {
94 get { return w.IsCustomErrorEnabled; }
97 public override bool IsDebuggingEnabled {
98 get { return w.IsDebuggingEnabled; }
101 public override bool IsPostNotification {
102 get { return w.IsPostNotification; }
105 public override IDictionary Items {
106 get { return w.Items; }
109 public override IHttpHandler PreviousHandler {
110 get { return w.PreviousHandler; }
113 public override ProfileBase Profile {
114 get { return w.Profile; }
117 public override HttpRequestBase Request {
118 get { return new HttpRequestWrapper (w.Request); }
121 public override HttpResponseBase Response {
122 get { return new HttpResponseWrapper (w.Response); }
125 public override HttpServerUtilityBase Server {
126 get { return new HttpServerUtilityWrapper (w.Server); }
129 public override HttpSessionStateBase Session {
130 get { return w.Session == null ? null : new HttpSessionStateWrapper (w.Session); }
133 public override bool SkipAuthorization {
134 get { return w.SkipAuthorization; }
135 set { w.SkipAuthorization = value; }
138 public override DateTime Timestamp {
139 get { return w.Timestamp; }
142 public override TraceContext Trace {
143 get { return w.Trace; }
146 public override IPrincipal User {
147 get { return w.User; }
148 set { w.User = value; }
151 public override void AddError (Exception errorInfo)
153 w.AddError (errorInfo);
156 public override void ClearError ()
161 public override object GetGlobalResourceObject (string classKey, string resourceKey)
163 return HttpContext.GetGlobalResourceObject (classKey, resourceKey);
166 public override object GetGlobalResourceObject (string classKey, string resourceKey, CultureInfo culture)
168 return HttpContext.GetGlobalResourceObject (classKey, resourceKey, culture);
171 public override object GetLocalResourceObject (string overridePath, string resourceKey)
173 return HttpContext.GetLocalResourceObject (overridePath, resourceKey);
176 public override object GetLocalResourceObject (string overridePath, string resourceKey, CultureInfo culture)
178 return HttpContext.GetLocalResourceObject (overridePath, resourceKey, culture);
181 public override object GetSection (string sectionName)
183 return w.GetSection (sectionName);
186 public override object GetService (Type serviceType)
188 return ((IServiceProvider)w).GetService (serviceType);
191 public override void RemapHandler (IHttpHandler handler)
193 w.RemapHandler (handler);
196 public override void RewritePath (string path)
198 w.RewritePath (path);
201 public override void RewritePath (string path, bool rebaseClientPath)
203 w.RewritePath (path, rebaseClientPath);
206 public override void RewritePath (string filePath, string pathInfo, string queryString)
208 w.RewritePath (filePath, pathInfo, queryString);
211 public override void RewritePath (string filePath, string pathInfo, string queryString, bool setClientFilePath)
213 w.RewritePath (filePath, pathInfo, queryString, setClientFilePath);
216 public override void SetSessionStateBehavior (SessionStateBehavior sessionStateBehavior)
218 w.SetSessionStateBehavior (sessionStateBehavior);