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;
43 [TypeForwardedFrom ("System.Web.Abstractions, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
44 [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
45 [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
46 public class HttpContextWrapper : HttpContextBase
50 public HttpContextWrapper (HttpContext httpContext)
52 if (httpContext == null)
53 throw new ArgumentNullException ("httpContext");
57 public override Exception [] AllErrors {
58 get { return w.AllErrors; }
61 public override HttpApplicationStateBase Application {
62 get { return new HttpApplicationStateWrapper (w.Application); }
65 public override HttpApplication ApplicationInstance {
66 get { return w.ApplicationInstance; }
67 set { w.ApplicationInstance = value; }
70 public override Cache Cache {
71 get { return w.Cache; }
74 public override IHttpHandler CurrentHandler {
75 get { return w.CurrentHandler; }
78 public override RequestNotification CurrentNotification {
79 get { return w.CurrentNotification; }
82 public override Exception Error {
83 get { return w.Error; }
86 public override IHttpHandler Handler {
87 get { return w.Handler; }
88 set { w.Handler = value; }
91 public override bool IsCustomErrorEnabled {
92 get { return w.IsCustomErrorEnabled; }
95 public override bool IsDebuggingEnabled {
96 get { return w.IsDebuggingEnabled; }
99 public override bool IsPostNotification {
100 get { return w.IsPostNotification; }
103 public override IDictionary Items {
104 get { return w.Items; }
107 public override IHttpHandler PreviousHandler {
108 get { return w.PreviousHandler; }
111 public override ProfileBase Profile {
112 get { return w.Profile; }
115 public override HttpRequestBase Request {
116 get { return new HttpRequestWrapper (w.Request); }
119 public override HttpResponseBase Response {
120 get { return new HttpResponseWrapper (w.Response); }
123 public override HttpServerUtilityBase Server {
124 get { return new HttpServerUtilityWrapper (w.Server); }
127 public override HttpSessionStateBase Session {
128 get { return w.Session == null ? null : new HttpSessionStateWrapper (w.Session); }
131 public override bool SkipAuthorization {
132 get { return w.SkipAuthorization; }
133 set { w.SkipAuthorization = value; }
136 public override DateTime Timestamp {
137 get { return w.Timestamp; }
140 public override TraceContext Trace {
141 get { return w.Trace; }
144 public override IPrincipal User {
145 get { return w.User; }
146 set { w.User = value; }
149 public override void AddError (Exception errorInfo)
151 w.AddError (errorInfo);
154 public override void ClearError ()
159 public override object GetGlobalResourceObject (string classKey, string resourceKey)
161 return HttpContext.GetGlobalResourceObject (classKey, resourceKey);
164 public override object GetGlobalResourceObject (string classKey, string resourceKey, CultureInfo culture)
166 return HttpContext.GetGlobalResourceObject (classKey, resourceKey, culture);
169 public override object GetLocalResourceObject (string overridePath, string resourceKey)
171 return HttpContext.GetLocalResourceObject (overridePath, resourceKey);
174 public override object GetLocalResourceObject (string overridePath, string resourceKey, CultureInfo culture)
176 return HttpContext.GetLocalResourceObject (overridePath, resourceKey, culture);
179 public override object GetSection (string sectionName)
181 return w.GetSection (sectionName);
184 public override object GetService (Type serviceType)
186 return ((IServiceProvider)w).GetService (serviceType);
188 public override void RemapHandler (IHttpHandler handler)
190 w.RemapHandler (handler);
192 public override void RewritePath (string path)
194 w.RewritePath (path);
197 public override void RewritePath (string path, bool rebaseClientPath)
199 w.RewritePath (path, rebaseClientPath);
202 public override void RewritePath (string filePath, string pathInfo, string queryString)
204 w.RewritePath (filePath, pathInfo, queryString);
207 public override void RewritePath (string filePath, string pathInfo, string queryString, bool setClientFilePath)
209 w.RewritePath (filePath, pathInfo, queryString, setClientFilePath);
211 public override void SetSessionStateBehavior (SessionStateBehavior sessionStateBehavior)
213 w.SetSessionStateBehavior (sessionStateBehavior);