feat: change SqlSessionStateProviderAsync.GetConnectionString to allow override
This commit is contained in:
Родитель
7655d1fae1
Коммит
8b18259234
|
@ -92,7 +92,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Data.SqlClient">
|
||||
<Version>5.0.0</Version>
|
||||
<Version>5.2.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
|
|
@ -384,8 +384,29 @@ namespace Microsoft.AspNet.SessionState
|
|||
public override bool SetItemExpireCallback(System.Web.SessionState.SessionStateItemExpireCallback expireCallback)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the connection string based on the connectionstring name
|
||||
/// </summary>
|
||||
/// <param name="connectionstringName">string</param>
|
||||
/// <returns></returns>
|
||||
protected virtual ConnectionStringSettings GetConnectionString(string connectionstringName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(connectionstringName))
|
||||
{
|
||||
throw new ProviderException(SR.Connection_name_not_specified);
|
||||
}
|
||||
ConnectionStringSettings conn = ConfigurationManager.ConnectionStrings[connectionstringName];
|
||||
|
||||
if (conn == null)
|
||||
{
|
||||
throw new ProviderException(
|
||||
String.Format(CultureInfo.CurrentCulture, SR.Connection_string_not_found, connectionstringName));
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
||||
private async Task<GetItemResult> DoGet(HttpContextBase context, string id, bool exclusive, CancellationToken cancellationToken)
|
||||
{
|
||||
if (id.Length > SessionIDManager.SessionIDMaxLength)
|
||||
|
@ -585,21 +606,6 @@ namespace Microsoft.AspNet.SessionState
|
|||
{
|
||||
Interlocked.CompareExchange(ref s_inPurge, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private static ConnectionStringSettings GetConnectionString(string connectionstringName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(connectionstringName))
|
||||
{
|
||||
throw new ProviderException(SR.Connection_name_not_specified);
|
||||
}
|
||||
ConnectionStringSettings conn = ConfigurationManager.ConnectionStrings[connectionstringName];
|
||||
if (conn == null)
|
||||
{
|
||||
throw new ProviderException(
|
||||
String.Format(CultureInfo.CurrentCulture, SR.Connection_string_not_found, connectionstringName));
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче