c# - Adding X-Frame-Options header to all pages in MVC 4 application -
i trying add x-frame-options header (with value set "deny") mvc 4 application. looked around , seems this cleanest way add pages.
however when add code not build. error on onresultexecuting of
"no suitable method found override."
public class xframeoptions : actionfilterattribute { public override void onresultexecuting( system.web.mvc.resultexecutingcontext filtercontext) { filtercontext.httpcontext.response.addheader( "x-frame-options", "deny"); } } if cleanest way how can resolve error? there better way handle in mvc 4 application?
make sure inherit correct class:
public class xframeoptions : system.web.mvc.actionfilterattribute in asp.net mvc 4 there's web api has different namespace , since haven't explicitly specified namespace guess compiler picking wrong class:
system.web.http.filters.actionfilterattribute
Comments
Post a Comment