1

I am currently developing an application in Blazor Server for a company. The application is just a landing page with some information.

The way it works is that when the company's homepage is down for maintenance, the dns will be pointed to the IP of my solution instead and show information from an SQL database based on the hostname it has been redirected from. So far so good, all is working well.

I have a problem though. One of the requirements is that the application have to return a 307 (Temporary redirect) status code in order for google to understand that it is temporary.

But when I add this middleware to my Startup.cs:

   app.Use(async (context, next) => {
     context.Response.StatusCode = 307;
     await next.Invoke();
   });

the following error is occuring:

Error: Cannot send data if the connection is not in the 'Connected' State.

It seems that it has something to do with SignalR. Maybe it anticipates a page with status code 200? I am not familiar with the underlying logic of SignalR.

So my question is: Is there a workaround, so I can serve my blazor app to the client with a status code 307?

Thanks in advance.

  • I don't know if my idea is correct or if I fully understand the concept behind 307, but ai think that the workflow should be _page A_ redirect temporarily (code 307) to _page B_. Page B should return 200. – Nicola Biada Sep 10 '21 at 19:16
  • To send a response with a custom header I think you need to rewrite the entire response. Like here https://stackoverflow.com/questions/40019012/modify-static-file-response-in-asp-net-core/40019112#40019112 – Nicola Biada Sep 10 '21 at 19:22

0 Answers0