In a small ASP.NET MVC test application, I added the appropriate httpProtocol
code to the web.config
file, as described in this article:
<system.webServer>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
<httpProtocol>
<customHeaders>
<add name="Content-Security-Policy" value="default-src 'self'" />
</customHeaders>
</httpProtocol>
</system.webServer>
However, on a test page in the application, the Vue.js code still works, which, since it is being loaded from a CDN, the content security policy should be blocking it.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home Page2 - Meine ASP.NET-Anwendung</title>
<link href="/Content/bootstrap.css" rel="stylesheet"/>
<link href="/Content/site.css" rel="stylesheet"/>
<script src="/Scripts/modernizr-2.6.2.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.4/vue.js"></script>
</head>
<body>
<div class="container mainMenu">
<ul>
<li><a href="/">Start Page</a></li>
<li><a href="/Home/About">About</a></li>
<li><a href="/Home/Contact">Contact</a></li>
<li><a href="/Home/Info">Info</a></li>
</ul>
</div>
<div class="container body-content">
<hr/>
<div id="app">
this is a test: <b>{{message}}</b>
</div>
<script>
var app = new Vue({
el: '#app',
data: {
message: 'Vue.js ready'
}
});
</script>
<hr/>
<footer>
<p>The footer</p>
</footer>
</div>
<script src="/Scripts/jquery-1.10.2.js"></script>
<script src="/Scripts/bootstrap.js"></script>
<script src="/Scripts/respond.js"></script>
</body>
</html>
What do I have to do to get the Content Security Policy to actually take effect in my site?
ADDENDUM
I can see in my dev tools, that the Content-Security-Policy is not being sent in the response headers: