0

Is there a way to edit the HTTP header "connection" in MVC. I tried the Add and AppendHeader functions; they all work, but you cannot edit the connection header.

I know that MVC provides certain standard HTTP headers to be modified by making some of the header values a public variable of that request for editing, such as StatusCode, but is there a way to edit the connection?

1 Answer 1

1

You can't really change/set headers on incoming request ("connection" is set by client side of the request, usually browser). You can add such header to response, but it will have no meaning to either side (server or browser)

HTTP/1.1 - Header Filed Definituions - Connection:

The Connection general-header field allows the sender to specify options that are desired for that particular connection

Sign up to request clarification or add additional context in comments.

3 Comments

I know about the rfc but What I am trying to do it already non standard, So I understand that developers who wrote IIS stuck to the standards. But is there a hacky way to do it. Like If I had an ASP project would that change anything, I doubt it, as they use the same framework.
@EvrenBingøl - side note: proper way to add non-standard headers is to use "x-" prefix for header name.
I am trying to hijack the request and start a websocket listening thread. So I have to handle Connection : Upgrade. I want to embed this in IIS running on port 80. I can create a separate thread and listen to some other port this is not the point of my project. So i am trying to handle the websocket initial connection with a controller/handler (mvc way) and change the header and respond back with a valid websocket token. so adding "x-" really not an option. All i have to do is some how for to send "Connection : Upgrade" key value pair back to client. I got all the necessary headers down

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.