@@ -27,7 +27,10 @@ public override void OnActionExecuting(ActionExecutingContext filterContext)
27
27
28
28
// if a param came in on querystring, skip the defaults. cookie already does its own skip.
29
29
if ( ! context . IsDefaultSkipped && filterContext . ActionParameters . Any ( x => x . Value != null && parentKeys . Contains ( x . Key ) ) )
30
+ {
30
31
context . IsDefaultSkipped = true ;
32
+ context . IsDeepLink = true ;
33
+ }
31
34
32
35
foreach ( var param in filterContext . ActionParameters . ToList ( ) )
33
36
{
@@ -49,6 +52,11 @@ public override void OnActionExecuting(ActionExecutingContext filterContext)
49
52
}
50
53
}
51
54
}
55
+ else if ( filterContext . ActionParameters . TryGetValue ( "_isDeepLink" , out object value ) )
56
+ {
57
+ if ( Convert . ToBoolean ( value ) == true )
58
+ context . IsDeepLink = true ;
59
+ }
52
60
}
53
61
54
62
base . OnActionExecuting ( filterContext ) ;
@@ -59,58 +67,62 @@ public override void OnActionExecuted(ActionExecutedContext filterContext)
59
67
if ( filterContext . Result is GriddlyResult result )
60
68
{
61
69
var context = filterContext . Controller . GetOrCreateGriddlyContext ( ) ;
62
- var request = filterContext . HttpContext . Request ;
63
70
64
- Uri parentPath = filterContext . IsChildAction ? request . Url : request . UrlReferrer ;
65
- string parentPathString = parentPath ? . PathAndQuery . Split ( '?' ) [ 0 ] ; // TODO: less allocations than split
66
-
67
- if ( parentPathString ? . Length > 0 )
71
+ if ( ! context . IsDeepLink )
68
72
{
69
- HttpCookie cookie = new HttpCookie ( "gf_" + context . Name )
70
- {
71
- Path = parentPathString
72
- } ;
73
+ var request = filterContext . HttpContext . Request ;
74
+
75
+ Uri parentPath = filterContext . IsChildAction ? request . Url : request . UrlReferrer ;
76
+ string parentPathString = parentPath ? . PathAndQuery . Split ( '?' ) [ 0 ] ; // TODO: less allocations than split
73
77
74
- GriddlyFilterCookieData data = new GriddlyFilterCookieData ( )
78
+ if ( parentPathString ? . Length > 0 )
75
79
{
76
- Values = new Dictionary < string , string [ ] > ( )
77
- } ;
80
+ HttpCookie cookie = new HttpCookie ( "gf_" + context . Name )
81
+ {
82
+ Path = parentPathString
83
+ } ;
78
84
79
- if ( context . SortFields ? . Length > 0 )
80
- data . SortFields = context . SortFields ;
85
+ GriddlyFilterCookieData data = new GriddlyFilterCookieData ( )
86
+ {
87
+ Values = new Dictionary < string , string [ ] > ( )
88
+ } ;
81
89
82
- // now, we could use the context.Parameters... but the raw string values seems more like what we want here...
83
- foreach ( var param in filterContext . ActionDescriptor . GetParameters ( ) )
84
- {
85
- var valueResult = filterContext . Controller . ValueProvider . GetValue ( param . ParameterName ) ;
90
+ if ( context . SortFields ? . Length > 0 )
91
+ data . SortFields = context . SortFields ;
86
92
87
- if ( valueResult ? . RawValue != null )
93
+ // now, we could use the context.Parameters... but the raw string values seems more like what we want here...
94
+ foreach ( var param in filterContext . ActionDescriptor . GetParameters ( ) )
88
95
{
89
- if ( valueResult . RawValue is string [ ] array )
90
- data . Values [ param . ParameterName ] = array ;
91
- else
92
- data . Values [ param . ParameterName ] = new [ ] { valueResult . RawValue . ToString ( ) } ;
96
+ var valueResult = filterContext . Controller . ValueProvider . GetValue ( param . ParameterName ) ;
97
+
98
+ if ( valueResult ? . RawValue != null )
99
+ {
100
+ if ( valueResult . RawValue is string [ ] array )
101
+ data . Values [ param . ParameterName ] = array ;
102
+ else
103
+ data . Values [ param . ParameterName ] = new [ ] { valueResult . RawValue . ToString ( ) } ;
104
+ }
93
105
}
94
- }
95
106
96
- // ... but if it is a defaults situation, we actually need to grab those
97
- if ( filterContext . IsChildAction && ! context . IsDefaultSkipped && context . Defaults . Count > 0 )
98
- {
99
- foreach ( var param in context . Defaults )
107
+ // ... but if it is a defaults situation, we actually need to grab those
108
+ if ( filterContext . IsChildAction && ! context . IsDefaultSkipped && context . Defaults . Count > 0 )
100
109
{
101
- if ( param . Value != null )
110
+ foreach ( var param in context . Defaults )
102
111
{
103
- var value = GriddlyExtensions . GetFormattedValueByType ( param . Value ) ;
112
+ if ( param . Value != null )
113
+ {
114
+ var value = GriddlyExtensions . GetFormattedValueByType ( param . Value ) ;
104
115
105
- if ( value != null )
106
- data . Values [ param . Key ] = value ;
116
+ if ( value != null )
117
+ data . Values [ param . Key ] = value ;
118
+ }
107
119
}
108
120
}
109
- }
110
121
111
- cookie . Value = JsonConvert . SerializeObject ( data ) ;
122
+ cookie . Value = JsonConvert . SerializeObject ( data ) ;
112
123
113
- filterContext . HttpContext . Response . Cookies . Add ( cookie ) ;
124
+ filterContext . HttpContext . Response . Cookies . Add ( cookie ) ;
125
+ }
114
126
}
115
127
}
116
128
0 commit comments