Skip to content

Commit 1ad631f

Browse files
Ruoyun Tangruta
authored andcommitted
update httpcontextbase and wrapper
1 parent 1a87ca5 commit 1ad631f

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ public partial class HttpContextBase : System.IServiceProvider
186186
public virtual void RewritePath(string path, bool rebaseClientPath) { 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) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
188188
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");}
189+
public virtual void SetSessionStateBehavior(System.Web.SessionState.SessionStateBehavior sessionStateBehavior) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
189190
}
190191
public partial class HttpContextWrapper : System.Web.HttpContextBase
191192
{
@@ -211,6 +212,7 @@ public partial class HttpContextWrapper : System.Web.HttpContextBase
211212
public override void RewritePath(string path, bool rebaseClientPath) { 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) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
213214
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");}
215+
public override void SetSessionStateBehavior(System.Web.SessionState.SessionStateBehavior sessionStateBehavior) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
214216
}
215217
public sealed partial class HttpCookie
216218
{

src/Microsoft.AspNetCore.SystemWebAdapters/HttpContext.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,18 @@ public ISubscriptionToken DisposeOnPipelineCompleted(IDisposable target)
166166
_context.Response.RegisterForDispose(token);
167167
return token;
168168
}
169+
public void SetSessionStateBehavior(SessionStateBehavior sessionStateBehavior)
170+
{
171+
if (_context.Features.Get<ISessionStateFeature>() is { } feature)
172+
{
173+
feature.State = sessionStateBehavior;
174+
}
175+
else
176+
{
177+
var newFeature = new SessionStateFeature() { State = sessionStateBehavior };
178+
_context.Features.Set<ISessionStateFeature>(newFeature);
179+
}
180+
}
169181

170182
[return: NotNullIfNotNull(nameof(context))]
171183
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)