Im trying to change all my ASP MVC HTTP response headers to have another value by default for implementing Pingback auto-discovery in my blog application.
The defaul
I know this post is old...but wanted to point out that while OnResultExecuting is the proper method to be doing this from, the original post shows that he was trying to add headers to the request. One does not simply add headers to a request and expect them to show up in the response. ;-)
Also, the proper way to add headers to a response...that also works in Cassini...is to use the following:
filterContext.HttpContext.Response.AddHeader("X-My-Request-Header", "works in cassini");
I believe your problem may be simply that you are trying to modify the headers too late, since you're doing it in OnResultExecuted
. Try overriding OnResultExecuting
instead.
http://msdn.microsoft.com/en-us/library/system.web.mvc.actionfilterattribute.onresultexecuting.aspx
This may or may not work (obviously if it doesn't I'll delete the answer for future users). It sounds like from the exception Operation is not supported by this platform
, that Cassini many not support custom headers (which would be quite strange, but a possibility). What I would suggest is to make sure you are using Visual Studio 2010 SP1, then install IIS Express (which is an upgrade to Cassini and is much more like real IIS), and then switch your project to use IIS Express and see if you get the same exception.
Additionally, you may want to review Why does HttpCacheability.Private suppress ETags? as it may also give you an alternative solution.