File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,13 +94,21 @@ private async Task<IServer> GetServer()
9494
9595 private async Task ConnectToRedisAsync ( )
9696 {
97- //TODO: Need to make this more robust. Also want to understand why the static connection method cannot accept dns names.
98- var ips = await Dns . GetHostAddressesAsync ( _settings . ConnectionString ) ;
99- _logger . LogInformation ( $ "Connecting to database { _settings . ConnectionString } at IP { ips . First ( ) . ToString ( ) } ") ;
100- _redis = await ConnectionMultiplexer . ConnectAsync ( ips . First ( ) . ToString ( ) ) ;
97+ // TODO: Need to make this more robust. ConnectionMultiplexer.ConnectAsync doesn't like domain names or IPv6 addresses.
98+ if ( IPAddress . TryParse ( _settings . ConnectionString , out var ip ) )
99+ {
100+ _redis = await ConnectionMultiplexer . ConnectAsync ( ip . ToString ( ) ) ;
101+ _logger . LogInformation ( $ "Connecting to database at { _settings . ConnectionString } ") ;
102+ }
103+ else
104+ {
105+ // workaround for https://github.com/StackExchange/StackExchange.Redis/issues/410
106+ var ips = await Dns . GetHostAddressesAsync ( _settings . ConnectionString ) ;
107+ _logger . LogInformation ( $ "Connecting to database { _settings . ConnectionString } at IP { ips . First ( ) . ToString ( ) } ") ;
108+ _redis = await ConnectionMultiplexer . ConnectAsync ( ips . First ( ) . ToString ( ) ) ;
109+ }
101110 }
102-
103-
111+
104112 }
105113}
106114
Original file line number Diff line number Diff line change @@ -57,6 +57,11 @@ public void ConfigureServices(IServiceCollection services)
5757
5858 services . Configure < AppSettings > ( Configuration ) ;
5959
60+ services . AddDataProtection ( opts =>
61+ {
62+ opts . ApplicationDiscriminator = "eshop.identity" ;
63+ } ) ;
64+
6065 services . AddMvc ( ) ;
6166
6267 services . AddHealthChecks ( checks =>
Original file line number Diff line number Diff line change @@ -44,6 +44,11 @@ public Startup(IHostingEnvironment env)
4444 // This method gets called by the runtime. Use this method to add services to the container.
4545 public void ConfigureServices ( IServiceCollection services )
4646 {
47+ services . AddDataProtection ( opts =>
48+ {
49+ opts . ApplicationDiscriminator = "eshop.webmvc" ;
50+ } ) ;
51+
4752 services . AddMvc ( ) ;
4853 services . Configure < AppSettings > ( Configuration ) ;
4954
Original file line number Diff line number Diff line change @@ -51,6 +51,11 @@ public void ConfigureServices(IServiceCollection services)
5151
5252 services . Configure < AppSettings > ( Configuration ) ;
5353
54+ services . AddDataProtection ( opts =>
55+ {
56+ opts . ApplicationDiscriminator = "eshop.webspa" ;
57+ } ) ;
58+
5459 services . AddAntiforgery ( options => options . HeaderName = "X-XSRF-TOKEN" ) ;
5560
5661 services . AddMvc ( )
You can’t perform that action at this time.
0 commit comments