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

Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase is not working in .net core 2.0 above versions #2240

Closed
synckarthik opened this issue Jan 21, 2019 · 10 comments
Assignees

Comments

@synckarthik
Copy link

synckarthik commented Jan 21, 2019

Issue Title

Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase is not working in .net core 2.0 above versions

General

We used the html upload box in our project. While upload fails, we will pass the custom message through httprequest to client side. Our server side section is in .net core project (2.0). So we have used the below code to send custom message

Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = "File already exists.";

It working fine.

While using the above code in .net core 2.1 project, it does not works.

How to resolve this in our side? Please suggest your ideas.

@karelz
Copy link
Member

karelz commented Jan 22, 2019

@synckarthik can you please post full .NET Core 2.1+ repro that we can route to the right team? Thanks!

@karelz karelz added the needs-more-info Not enough information has been provided. Please share more detail as requested. label Jan 22, 2019
@synckarthik
Copy link
Author

synckarthik commented Jan 23, 2019

Hi Guys,

I have attached the sample for HTML 5 uploader with xmlHttpRequest to send the form data.

Steps to reproduce:

Run the sample and select any file. Then click on uploadFile button,. Your file will be uploaded in to wwwroot folder now.
Upload the same file again, you will receive the custom message which we sent from server end 'File Already Exists' in load event.

But message not received in dotnet core 2.1 project.

Below you can get 2.0 project.

UploaderDotNetCore2Point0.zip

Below you can get 2.1 project.

UploadDotnetcore2Point1.zip

Please check it.

@karelz karelz added area-aspnet and removed needs-more-info Not enough information has been provided. Please share more detail as requested. labels Jan 23, 2019
@synckarthik
Copy link
Author

Hi @karelz / @Eilon , Any ideas on this issue?

@karelz
Copy link
Member

karelz commented Jan 24, 2019

@synckarthik no idea from me - when @Eilon is back, he can route it on ASP.NET team.

@karelz
Copy link
Member

karelz commented Jan 24, 2019

@muratg can you please help move it & route it on ASP.NET team while @Eilon is OOF?

@muratg
Copy link

muratg commented Jan 24, 2019

@Tratcher Can you take a look?

@Tratcher
Copy link
Member

@synckarthik I was able to reproduce this with your samples and I see the difference. This is not caused by any code changes in the framework, it's caused by a project configuration change.

The 2.0 project templates did not have HTTPS enabled by default, the 2.1 templates do. When using HTTP the browser uses HTTP/1.1 and ReasonPhrase works as expected. When using HTTPS the browser uses HTTP/2 and ReasonPhrase no longer works. The reason it doesn't work is because the HTTP/2 protocol has removed the concept of ReasonPhrase. That's one of the reasons we excluded it from HttpResponse.

Suggested workaround: use a custom header instead.

@synckarthik
Copy link
Author

@Tratcher , Thank you for your detailed explanation. I will use custom header.

@Gopigovin
Copy link

Gopigovin commented Mar 14, 2019

Hi Guys,

Http response custom header not working properly asp.net core 2.2 web api response.

We used the html upload box in our project. While upload fails, we will pass the custom message through httprequest to client side. Our server side section is in .net core project (2.1). So we have used the below code to send custom message

Response.Headers.Add("status", "File processed correctly");

It working fine core 2.1. While using the above code in .net core 2.2 project, it does not works.

How to resolve this in our side? Please suggest your ideas.

Regards,
Gopi G

@Tratcher
Copy link
Member

Are you sure it's not using Http/2 a like discussed above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants