Whatever happened to Response.Headers.Add from the friendly web code I'm so used to... Oh well, after scratching around for ages I finally found how:
var prop = new HttpResponseMessageProperty(); prop.Headers.Add("ApiVersion", "v1.0"); OperationContext.Current.OutgoingMessageProperties.Add(HttpResponseMessageProperty.Name, prop);
I know you're kicking yourself, right? "That's so obvious..." Ridiculous - I'm starting to thing WCF REST wasn't made with the developer in mind.
Update:
Actually, there is an easier way I found. Since this is in a REST service it is possible to use WebOperationContext which seems a lot more intuitive and concise:WebOperationContext.Current.OutgoingResponse.Headers.Add("ApiVersion", "v1.0");
It's not that WCF REST wasn't made with the developer in mind; it's that WCF wasn't made with only REST in mind.
ReplyDeleteIf a cookie was going to be added to a header, how could it be set to expire after 30 days from current datetime?
ReplyDeleteMotifz Designer Lawn. 1, 2 & 3 Piece Unstitched Premium Embroidered Lawn 2019, Premium embroidered Lawn, Premium lawn, Premium lawn 2019, Motifz, Premium lawn in Pakistan, Summer collection. Shipping worldwide. Stitching option available.
ReplyDeleteI know you're kicking yourself, right? "That's so obvious..." Ridiculous - I'm starting to thing WCF REST wasn't made with the developer in mind. 4inkjets coupons
ReplyDelete
ReplyDeleteشركة تنظيف الامارات
شركة تنظيف دبي شركة نظافة بدبي
شركة تنظيف كنب دبي بالبخار تنظيف كنب دبي بالبخار
شركة غسيل سجاد بدبي غسيل سجاد دبي
شركة تنظيف في ابوظبي شركات تنظيف ابوظبي
شركة تنظيف منازل فى العين شركة تنظيف منازل العين
شركات تنظيف كنب في ابوظبي شركات تنظيف كنب ابوظبي
Great Article
ReplyDeleteCloud Computing Projects
Networking Projects
Final Year
Projects for CSE
JavaScript Training in Chennai
JavaScript
Training in Chennai
The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals,
Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer.
Angular Training