delphimvcframework icon indicating copy to clipboard operation
delphimvcframework copied to clipboard

Broken rotes in ISAPI module

Open FreezerUa opened this issue 6 months ago • 1 comments

After commit 42f1556 framework starts to use ARequest.RAWPathInfo instead of ARequest.PathInfo for routing purpose, but when WebApplication is compiled as ISAPI module ARequest filled by IIS and RAWPathInfo property always returns empty string, so all routes is broken. Need to revert changes or make some special handling of this situation.

FreezerUa avatar Jun 04 '25 13:06 FreezerUa

Which Delphi version? How do you debug your ISAPI?

danieleteti avatar Jun 06 '25 21:06 danieleteti

Any news?

danieleteti avatar Aug 10 '25 09:08 danieleteti

Sorry for long delay. Delphi 12.3, Win11 + Win10 + Win2016 Debug as always by Delphi debugger + logs in production.

I was invastigate the problem and it's not really true that RAWPathInfo is always empty, it's just canculated by another rule. I made test Application named like IISTest.dll which is standard IsapiModule with code:

 procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  xJson : TJSONObject;
begin
  xJson := TJSONObject.Create;
  try
    xJson.AddPair('RawPathInfo', Request.RawPathInfo);
    xJson.AddPair('PathInfo', Request.PathInfo);
    xJson.AddPair('InternalPathInfo', Request.InternalPathInfo);
    xJson.AddPair('PathTranslated', Request.PathTranslated);

    Response.ContentType := 'application/json';
    Response.Content := xJson.ToJSON;
  finally
    xJson.Free;
  end;
end; 

I use default IIS site located in C:\inetpub\wwwroot\, Create adiditional folder C:\inetpub\TestBackend\ Add to site Handler mapping, that is configurated like: ModuleMapping: Requested Path: /api Module: IsapiModule Verbs: All verbs Access: Execute So all requests to site started with /api will be handled by test application. And here is test results: Request: http://localhost/api Response: {"RawPathInfo":"","PathInfo":"/api","InternalPathInfo":"/api","PathTranslated":"C:\inetpub\wwwroot\api"}

Request: http://localhost/api/swagger Response: {"RawPathInfo":"/swagger","PathInfo":"/api/swagger","InternalPathInfo":"/api/swagger","PathTranslated":"C:\inetpub\wwwroot\api\swagger"}

So seams like RawPathInfo does not include map-part of path.

That's why this commit broke mapping of my production server.

One more thing: if we reconfigurate mapping module like: Requested Path: /api/* Module: IsapiModule Verbs: All verbs Access: Execute and do test:

Request: http://localhost/api/ Response: {"RawPathInfo":"","PathInfo":"/api/","InternalPathInfo":"/api/","PathTranslated":"C:\inetpub\wwwroot\api\"}

Request: http://localhost/api/swagger Response: {"RawPathInfo":"","PathInfo":"/api/swagger","InternalPathInfo":"/api/swagger","PathTranslated":"C:\inetpub\wwwroot\api\swagger"}

As you can see, now whole URL is map-part of path, so RawPathInfo is always empty

FreezerUa avatar Aug 11 '25 08:08 FreezerUa

I remember seeing some differences between localhost and isapi path behaviour a few years ago - this was not a DMVC application though, IIRC it was a Webbroker SOAP server. The first part of the path got stripped ssomewhere.

I'll need to go back through some old notes .....

fastbike avatar Aug 11 '25 09:08 fastbike

In my first test environment handler mapping was configured like Requested Path: *, thats why i always get empty RawPathInfo

FreezerUa avatar Aug 12 '25 07:08 FreezerUa