File tree 3 files changed +26
-8
lines changed
3 files changed +26
-8
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ var reactComponent
123
123
124
124
var executionResult = reactComponent . RenderRouterWithContext ( clientOnly , serverOnly ) ;
125
125
126
- if ( executionResult . Context ? . status != null )
126
+ if ( executionResult . Context ? . status != null || executionResult . Context ? . url != null )
127
127
{
128
128
// Use provided contextHandler
129
129
if ( contextHandler != null )
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public static class SetServerResponse
36
36
/// <param name="Response">The response object to use.</param>
37
37
public static void ModifyResponse ( RoutingContext context , HttpResponse Response )
38
38
{
39
- var statusCode = context . status . Value ;
39
+ var statusCode = context . status ?? 302 ;
40
40
41
41
// 300-399
42
42
if ( statusCode >= 300 && statusCode < 400 )
Original file line number Diff line number Diff line change 1
- /*
1
+ /*
2
2
* Copyright (c) 2014-Present, Facebook, Inc.
3
3
* All rights reserved.
4
4
*
7
7
* of patent rights can be found in the PATENTS file in the same directory.
8
8
*/
9
9
10
+ using System . Web ;
11
+ using System . Web . Mvc ;
10
12
using Moq ;
11
- using Xunit ;
12
- using React . Exceptions ;
13
13
using React . Router ;
14
14
using React . Tests . Core ;
15
- using System . Web ;
16
- using JavaScriptEngineSwitcher . Core ;
17
- using System . Web . Mvc ;
15
+ using Xunit ;
18
16
19
17
namespace React . Tests . Router
20
18
{
@@ -231,6 +229,26 @@ public void ShouldRedirectPermanent()
231
229
htmlHelperMock . httpResponse . Verify ( x => x . RedirectPermanent ( It . IsAny < string > ( ) ) ) ;
232
230
}
233
231
232
+ [ Fact ]
233
+ public void ShouldRedirectWithJustUrl ( )
234
+ {
235
+ var mocks = ConfigureMockReactEnvironment ( ) ;
236
+ ConfigureMockConfiguration ( ) ;
237
+
238
+ mocks . Engine . Setup ( x => x . Evaluate < string > ( "JSON.stringify(context);" ) )
239
+ . Returns ( @"{ url: ""/foo"" }" ) ;
240
+
241
+ var htmlHelperMock = new HtmlHelperMocks ( ) ;
242
+
243
+ HtmlHelperExtensions . ReactRouterWithContext (
244
+ htmlHelper : htmlHelperMock . htmlHelper . Object ,
245
+ componentName : "ComponentName" ,
246
+ props : new { } ,
247
+ path : "/"
248
+ ) ;
249
+ htmlHelperMock . httpResponse . Verify ( x => x . Redirect ( It . IsAny < string > ( ) ) ) ;
250
+ }
251
+
234
252
[ Fact ]
235
253
public void ShouldFailRedirectWithNoUrl ( )
236
254
{
You can’t perform that action at this time.
0 commit comments