Skip to content

Commit 645b19f

Browse files
author
Ruoyun Tang
committed
update httpcontextbase and wrapper
1 parent c2f7c1c commit 645b19f

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

src/Microsoft.AspNetCore.SystemWebAdapters/Generated/Ref.Standard.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ public partial class HttpContextBase : System.IServiceProvider
185185
public virtual void RewritePath(string path, bool rebaseClientPath) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
186186
public virtual void RewritePath(string filePath, string pathInfo, string queryString) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
187187
public virtual void RewritePath(string filePath, string pathInfo, string queryString, bool setClientFilePath) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
188+
public virtual void SetSessionStateBehavior(System.Web.SessionState.SessionStateBehavior sessionStateBehavior) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
188189
}
189190
public partial class HttpContextWrapper : System.Web.HttpContextBase
190191
{
@@ -210,6 +211,7 @@ public partial class HttpContextWrapper : System.Web.HttpContextBase
210211
public override void RewritePath(string path, bool rebaseClientPath) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
211212
public override void RewritePath(string filePath, string pathInfo, string queryString) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
212213
public override void RewritePath(string filePath, string pathInfo, string queryString, bool setClientFilePath) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
214+
public override void SetSessionStateBehavior(System.Web.SessionState.SessionStateBehavior sessionStateBehavior) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
213215
}
214216
public sealed partial class HttpCookie
215217
{

src/Microsoft.AspNetCore.SystemWebAdapters/HttpContext.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,6 @@ public IPrincipal User
9292

9393
public HttpSessionState? Session => _context.Features.Get<HttpSessionState>();
9494

95-
public void SetSessionStateBehavior(SessionStateBehavior sessionStateBehavior)
96-
{
97-
if (_context.Features.Get<ISessionStateFeature>() is { } feature)
98-
{
99-
feature.State = sessionStateBehavior;
100-
}
101-
else
102-
{
103-
var newFeature = new SessionStateFeature() { State = sessionStateBehavior };
104-
_context.Features.Set<ISessionStateFeature>(newFeature);
105-
}
106-
}
107-
10895
public DateTime Timestamp { get; } = DateTime.UtcNow.ToLocalTime();
10996

11097
public void RewritePath(string path) => RewritePath(path, true);
@@ -166,6 +153,18 @@ public ISubscriptionToken DisposeOnPipelineCompleted(IDisposable target)
166153
_context.Response.RegisterForDispose(token);
167154
return token;
168155
}
156+
public void SetSessionStateBehavior(SessionStateBehavior sessionStateBehavior)
157+
{
158+
if (_context.Features.Get<ISessionStateFeature>() is { } feature)
159+
{
160+
feature.State = sessionStateBehavior;
161+
}
162+
else
163+
{
164+
var newFeature = new SessionStateFeature() { State = sessionStateBehavior };
165+
_context.Features.Set<ISessionStateFeature>(newFeature);
166+
}
167+
}
169168

170169
[return: NotNullIfNotNull(nameof(context))]
171170
public static implicit operator HttpContext?(HttpContextCore? context) => context?.GetAdapter();

src/Microsoft.AspNetCore.SystemWebAdapters/HttpContextBase.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Collections;
55
using System.Security.Principal;
66
using System.Diagnostics.CodeAnalysis;
7+
using System.Web.SessionState;
78
using Microsoft.AspNetCore.SystemWebAdapters;
89

910
namespace System.Web
@@ -67,5 +68,7 @@ public virtual IPrincipal User
6768
public virtual void RewritePath(string filePath, string pathInfo, string? queryString) => throw new NotImplementedException();
6869

6970
public virtual void RewritePath(string filePath, string pathInfo, string? queryString, bool setClientFilePath) => throw new NotImplementedException();
71+
72+
public virtual void SetSessionStateBehavior(SessionStateBehavior sessionStateBehavior) => throw new NotImplementedException();
7073
}
7174
}

src/Microsoft.AspNetCore.SystemWebAdapters/HttpContextWrapper.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,7 @@ public override IPrincipal User
7979
public override void RewritePath(string filePath, string pathInfo, string? queryString) => _context.RewritePath(filePath, pathInfo, queryString);
8080

8181
public override void RewritePath(string filePath, string pathInfo, string? queryString, bool setClientFilePath) => _context.RewritePath(filePath, pathInfo, queryString, setClientFilePath);
82+
83+
public override void SetSessionStateBehavior(SessionStateBehavior sessionStateBehavior) => _context.SetSessionStateBehavior(sessionStateBehavior);
8284
}
8385
}

0 commit comments

Comments
 (0)