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 asp.net Web API for backend and Angular 2 for front end.
Asked
Active
Viewed 1,430 times
0
-
You need to either send it on every request, or store it in server session state. Why are you resistant to sending it as part of the request? – jlew Nov 28 '16 at 13:13
-
I don't want to set it explicitly with every request body. Is there any way to send with http headers? – chenk Nov 28 '16 at 13:17
-
Sure: `var headers = new Headers(); headers.append('Content-Type', 'application/x-www-form-urlencoded'); this.http.post('http:/myurl', creds, { headers: headers })` – jlew Nov 28 '16 at 13:20
1 Answers
1
To add a header to a specific request:
var headers = new Headers();
headers.append('MyHeaderName','MyHeaderValue')
http.post('http://myurl', {/*body*/}, { headers: headers })
Alternatively, you could extend the http class and add a header to every request automatically, see here for details: