10-17-2019, 04:28 PM
Next dumb question:
In IWXI, I could set handled to true in the OnBeforeDispatch (after sending a bit of html to the response) and it would end the session there and then.
When I'm trying to do the same in IW XV, it *does* run the code, but seems to run the OnBeforeDispatch multiple times for a single connection, before either erroring or just rendering the front page of my app - there is no Handled property for me to tell it to stop.
What should I be using instead? I want to generate different html based on which subdomain was used to connect, and not have to redirect the URL
(IW XI code:
Responded := false;
Response.StatusCode := 200;
DirList := TStringList.Create;
GetSubDirectories(IncludeTrailingPathDelimiter(ExtractFileDir(ParamStr(0)))
+ 'wwwroot\googlebot', DirList);
if DirList.count > 0 then
for x := 0 to DirList.count - 1 do
begin
if pos(UpperCase(ExtractFileName(ExcludeTrailingPathDelimiter
(DirList[x]))), UpperCase(Request.Host)) > 0 then
begin
mystrings := TStringList.Create;
mystrings.LoadFromFile(DirList[x] + '\index.html');
Response.ContentType := 'text/html';
Response.content := '';
for y := 0 to mystrings.count - 1 do
begin
Response.content := Response.content + mystrings[y] + #10#13;
end;
Response.SendResponse;
Responded := true;
break;
end
end;
if not Responded then
begin
Response.ContentType := 'text/html';
Response.content := html;
Response.SendResponse;
end;
)
In IWXI, I could set handled to true in the OnBeforeDispatch (after sending a bit of html to the response) and it would end the session there and then.
When I'm trying to do the same in IW XV, it *does* run the code, but seems to run the OnBeforeDispatch multiple times for a single connection, before either erroring or just rendering the front page of my app - there is no Handled property for me to tell it to stop.
What should I be using instead? I want to generate different html based on which subdomain was used to connect, and not have to redirect the URL
(IW XI code:
Responded := false;
Response.StatusCode := 200;
DirList := TStringList.Create;
GetSubDirectories(IncludeTrailingPathDelimiter(ExtractFileDir(ParamStr(0)))
+ 'wwwroot\googlebot', DirList);
if DirList.count > 0 then
for x := 0 to DirList.count - 1 do
begin
if pos(UpperCase(ExtractFileName(ExcludeTrailingPathDelimiter
(DirList[x]))), UpperCase(Request.Host)) > 0 then
begin
mystrings := TStringList.Create;
mystrings.LoadFromFile(DirList[x] + '\index.html');
Response.ContentType := 'text/html';
Response.content := '';
for y := 0 to mystrings.count - 1 do
begin
Response.content := Response.content + mystrings[y] + #10#13;
end;
Response.SendResponse;
Responded := true;
break;
end
end;
if not Responded then
begin
Response.ContentType := 'text/html';
Response.content := html;
Response.SendResponse;
end;
)