![]() |
|
Set Response 403 from TContentForm.OnBeforeExecute - Printable Version +- Atozed Forums (https://www.atozed.com/forums) +-- Forum: Atozed Software (https://www.atozed.com/forums/forum-1.html) +--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html) +---- Forum: English (https://www.atozed.com/forums/forum-16.html) +----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html) +----- Thread: Set Response 403 from TContentForm.OnBeforeExecute (/thread-3435.html) |
Set Response 403 from TContentForm.OnBeforeExecute - jeroen.rottink - 08-31-2023 I have to check the IP from the client before allowing access to a page. I test this in TContentForm.OnBeforeExecute and would like to return 403 Forbidden Result is the exception 'Reply type already set.' Code: procedure TIWServerController.IWServerControllerBaseConfig(Sender: TObject);Using IW 15.3.12 RE: Set Response 403 from TContentForm.OnBeforeExecute - Alexandre Machado - 09-16-2023 Hi Jeroen, I was able to recreate it here. That's an interesting usage of the OnBeforeExeucte method of the content handler. It required a simple fix in the content handlers logic that will be available in the next release. BTW, you don't need to explicitly set the terminate message, once IW will return 403 - Forbidden, by default once you set the HttpCode, unless you want something different. Cheers RE: Set Response 403 from TContentForm.OnBeforeExecute - Mario Villalba - 07-17-2024 (09-16-2023, 09:14 PM)Alexandre Machado Wrote: Hola Jeroen, Hello Alexandre. You could modify the response code in the "IWServerControllerBaseExecuteRequest" event. When processing the request, if any exception is given, I need to return code 500. By directly assigning Response.Code := 500; It gives me the error 'Reply type already set.'. RE: Set Response 403 from TContentForm.OnBeforeExecute - Alexandre Machado - 07-31-2024 (07-17-2024, 10:11 PM)Mario Villalba Wrote: Hello Alexandre. Hi Mario, I'm not sure if I follow. Are you trapping the exception and directly assigning Response.Code := 500 or letting the exeption flow? RE: Set Response 403 from TContentForm.OnBeforeExecute - Mario Villalba - 07-31-2024 (07-31-2024, 07:14 AM)Alexandre Machado Wrote:(07-17-2024, 10:11 PM)Mario Villalba Wrote: Hello Alexandre. Hello Alexandre. I was able to solve it now. When catching the exception I was directly assigning "Response.Code := 500;" without first resetting the response "Response.ResetReplyType;" Thank you so much |