Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render(StatusCode, Object) returning wrong status code in ISAPI dll #406

Open
Rafnafnaf opened this issue Jul 22, 2020 · 5 comments
Open
Assignees
Labels
accepted Issue has been accepted and inserted in a future milestone need more info
Milestone

Comments

@Rafnafnaf
Copy link

I'm using version 3.1 lithium.

I'm calling the render method overload which accepts a statuscode and an object, and I want to return a 401 with an error object from the ControllerBeforeAction of my base controller.

When doing it with an executable VCL forms app, it works as expected.
When using the same code in an ISAPI dll, published in IIS, the status code is always 200.

I fixed it by using Render(object) and then calling Context.Response.StatusCode := 401

Note that in the log file, the correct status code was displayed for the response, so at first we thought that the problem was with IIS.

@dan5602
Copy link

dan5602 commented Aug 18, 2020

I am having the exact same issue when deploying an ISAPI dll to IIS.

Calling Context.Response.StatusCode := 401 after calling Render doesn't seem to fix the issue for me.
If I just call Context.Response.StatusCode := HTTP_STATUS.BadRequest; and comment out Render() the status code is as correct. (201 instead of 200)

I am using the latest release of DMVC (DelphiMVCFramework 3.2.0-boron).

@danieleteti danieleteti self-assigned this Aug 18, 2020
@danieleteti danieleteti added the accepted Issue has been accepted and inserted in a future milestone label Aug 18, 2020
@danieleteti danieleteti added this to the 3.2.1-carbon milestone Aug 18, 2020
@Rafnafnaf
Copy link
Author

Edit. My version is also 3.2, I made a mistake while writing the original comment.

@osaris
Copy link

osaris commented Sep 8, 2020

I confirm this issue, Render(422, 'string') is OK (response code 422) but Render(422, TObject) is not OK (response code 200). It works well when running our server in console.
I'm testing on master.

@fastbike
Copy link
Contributor

fastbike commented Sep 23, 2020

Have you enabled PassThrough error handling in the IIS app ? IIRC thisis required in the web.config file where your app is hosted.

<configuration>
    <system.webServer>
	  <httpErrors existingResponse="PassThrough" />
        <handlers>
            <add name="AppName" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\inetpub\pathToDLL\MVCServer.dll" resourceType="Unspecified" preCondition="bitness64" />
        </handlers>
    </system.webServer>
</configuration>

See https://stackoverflow.com/questions/31040671/what-does-existingresponse-passthrough-mean-in-iis

@osaris
Copy link

osaris commented Sep 25, 2020

PassThrough is enabled here and it doesn't work.

@danieleteti danieleteti removed this from the 3.2.1-carbon milestone Nov 27, 2020
@danieleteti danieleteti added this to the 3.4.1-sodium milestone Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Issue has been accepted and inserted in a future milestone need more info
Projects
None yet
Development

No branches or pull requests

5 participants