Skip to content

Commit 29f048d

Browse files
claudiamurialdoclaudiamurialdo
andauthored
Add null-safe checks in IsCrawlerRequest_impl (#1225)
* Add null-safe checks in IsCrawlerRequest_impl * Add null-safe checks in IsCrawlerRequest_impl. * Add null-safe checks in IsForward. * IsSubmited was not copied to UTL contexts. --------- Co-authored-by: claudiamurialdo <[email protected]>
1 parent a9e092e commit 29f048d

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,7 @@ public IGxContext UtlClone()
12441244
DataStoreUtil.LoadDataStores(ctx);
12451245
ctx.SetPhysicalPath(this.GetPhysicalPath());
12461246
ctx.SetSession(this.GetSession());
1247+
ctx._isSumbited = this.IsSubmited;
12471248
if (this.HttpContext != null)
12481249
{
12491250
ctx.HttpContext = this.HttpContext;
@@ -1289,22 +1290,38 @@ public bool IsForward()
12891290
{
12901291
if (_HttpContext != null)
12911292
{
1293+
#if NETCORE
1294+
object callMethodObj;
1295+
if (_HttpContext.Items.TryGetValue("gx_webcall_method", out callMethodObj))
1296+
{
1297+
1298+
string callMethod = callMethodObj as string;
1299+
if (!string.IsNullOrEmpty(callMethod) && (string.Compare(callMethod, "forward", true) == 0))
1300+
{
1301+
return true;
1302+
}
1303+
}
1304+
#else
12921305
string callMethod = (string)_HttpContext.Items["gx_webcall_method"];
12931306
if ((callMethod != null) && (string.Compare(callMethod, "forward", true) == 0))
12941307
{
12951308
return true;
12961309
}
1310+
#endif
12971311
}
12981312
return false;
12991313
}
13001314

13011315
public bool isCrawlerRequest_impl()
13021316
{
1303-
if (_HttpContext != null && _HttpContext.Request.QueryString.ToString().Contains("_escaped_fragment_"))
1304-
{
1305-
return true;
1306-
}
1307-
return false;
1317+
string query;
1318+
#if NETCORE
1319+
QueryString? queryString = (_HttpContext?.Request?.QueryString);
1320+
query = queryString.HasValue ? queryString.Value.ToString() : null;
1321+
#else
1322+
query = _HttpContext?.Request?.QueryString.ToString();
1323+
#endif
1324+
return !string.IsNullOrEmpty(query) && query.Contains("_escaped_fragment_");
13081325
}
13091326

13101327
public HtmlTextWriter OutputWriter

0 commit comments

Comments
 (0)