• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Kriztine Mendoza

Senior .NET Developer & Tech Partner for Scalable Software Solutions

  • Home
  • About
  • Work
  • Services
  • Contact Me

HTTP

X-Frame-Options header and X-Content-Type-Options = nosniff

September 19, 2017 by kriztine

X-Frame-Options header

According to Mozilla documentation, the X-Frame-Options HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a <frame>, <iframe> or <object> . Sites can use this to avoid clickjacking attacks, by ensuring that their content is not embedded into other sites.

X-Content-Type-Options = nosniff

According to MSDN, the X-Content-Type-Options: nosniff is a security feature that helps prevent attacks based on MIME-type confusion. If the server sends this response header, the script and stylesheet elements will reject responses with incorrect MIME types.

Example of MIME-sniffing:

Consider the case of a picture-sharing web service which hosts pictures uploaded by anonymous users. An attacker could upload a specially crafted JPEG file that contained script content, and then send a link to the file to unsuspecting victims. When the victims visited the server, the malicious file would be downloaded, the script would be detected, and it would run in the context of the picture-sharing site. This script could then steal the victim’s cookies, generate a phony page, etc.

Implementation of X-Frame-Options header and X-Content-Type-Options = nosniff

In order to implement these two options into our project, we need to add the following code to the project’s web.config file:

<system.webServer>
   …
   <httpProtocol>
        <customHeaders>
            <remove name="X-Content-Type-Options">
            <add name="X-Content-Type-Options" value="nosniff">
            <add name="X-Frame-Options" value="SAMEORIGIN" >
        </customHeaders>
   </httpProtocol>
   …
</system.webServer>

After updating the web.config, here are the results of the HTTP headers for different browsers.

mozilla x-frame-options
Mozilla Firefox

 

CHROME x-frame-options
Google Chrome

 

edge x-frame-options
Microsoft Edge

Filed Under: System Administration and Configuration Tagged With: HTTP

Primary Sidebar

Recent Posts

  • The tooltip or Intellisense for methods do not appear!
  • Scrollbar doesn’t show on Safari
  • WebResource.axd File Compression
  • X-Frame-Options header and X-Content-Type-Options = nosniff
  • Solved: Truncation Error when Importing from MS Excel to SQL Server

Categories

  • .Net Development (7)
  • Design (4)
  • How-To's (3)
  • Marketing (1)
  • Project Management (2)
  • Projects (1)
  • SQL (4)
  • System Administration and Configuration (2)
  • Tools (8)

Archives

SERVICES
  • Responsive Web Design
  • Custom Web/Software Development
  • Content Management System
  • API Development and Integration
  • Database Design and Management
  • System Configuration and Administration
QUICK LINKS
  • About
  • Services
  • Dev Notes
  • Resources
  • Contact me
GET IN TOUCH
  • +6349.539.1339
  • contact@kriztine.com
  • kriztine.tech@gmail.com

© 2025 · All Rights Reserved · Kriztine Mendoza

Attributions · Privacy Policy

"Whatever you do, work at it with all your heart, as working for the Lord..." - Colossians 3:23