chenk chenk - 1 year ago 119
HTTP Question

How to Send timezone info to server with http request?

I would like to do some timezone specific date manipulation on server. But I don't want to send the timezone via request payload for each and every http request. Any other work around there for achieve this? I use Web API for backend and Angular 2 for front end.

Answer Source

To add a header to a specific request:

var headers = new Headers();
headers.append('MyHeaderName','MyHeaderValue')'http://myurl', {/*body*/}, { headers: headers })

Alternatively, you could extend the http class and add a header to every request automatically, see here for details:

What is httpinterceptor equivalent in angular2?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download