{"id":833,"date":"2018-01-20T07:21:06","date_gmt":"2018-01-20T07:21:06","guid":{"rendered":"http:\/\/www.netexl.com\/blog\/?p=833"},"modified":"2026-04-02T10:00:31","modified_gmt":"2026-04-02T10:00:31","slug":"windows-10-app-host-defined-policy-inline-script-resource-will-be-blocked","status":"publish","type":"post","link":"https:\/\/www.netexl.com\/blog\/windows-10-app-host-defined-policy-inline-script-resource-will-be-blocked\/","title":{"rendered":"Windows 10 App :Host Defined Policy: Inline Script. Resource will be blocked."},"content":{"rendered":"<p>I recently ported one of my java script projects to Windows store app and got the error as following<\/p>\n<blockquote><p>CSP14321: Resource violated directive &#8216;script-src ms-appx: &#8216;unsafe-eval&#8217; blob:&#8217; in Host Defined Policy: inline script, in ms-appx:\/\/13bdc914-5111-4c95-a5e6-82029c5105ec\/index.html at line 21 column 12. Resource will be blocked.<\/p><\/blockquote>\n<p>If you have something like the following, it won&#8217;t work<\/p>\n<pre class=\"lang:default decode:true\">&lt;a href=\"javascript:void(0)\" id=\"somelink\" onclick=\"callMethod();\"&gt;Link&lt;\/a&gt;<\/pre>\n<p>Since I was using jQuery in the project, I simply used\u00a0jQuery to bind click event to the element<\/p>\n<pre class=\"lang:default decode:true\">$(\"#somelink\").click(function () {\r\n    callMethod();\r\n});\r\n<\/pre>\n<p>and Voila, everything works but I had many pages which had this reference and I had to make this change to all pages. After some research I found that there is an alternate way which is much faster to change. By default\u00a0<strong>ms-appx:\/\/\/<\/strong>\u00a0protocol is used in store apps to fetch the content. For web apps specify a specific protocal\u00a0<strong>ms-appx-web <\/strong>which is then used for the app. This can be done by changing start page from <strong>index.html<\/strong> to\u00a0<strong>ms-appx-web:\/\/\/index.html <\/strong>in package.appxmanifest. Also add\u00a0highlighted rule in your package.appxmanifest (You will need to\u00a0modify it in coding\u00a0view and not the visual editor)<\/p>\n<pre class=\"lang:default mark:23-25 decode:true\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;Package xmlns=\"http:\/\/schemas.microsoft.com\/appx\/manifest\/foundation\/windows10\" xmlns:mp=\"http:\/\/schemas.microsoft.com\/appx\/2014\/phone\/manifest\" xmlns:uap=\"http:\/\/schemas.microsoft.com\/appx\/manifest\/uap\/windows10\" IgnorableNamespaces=\"uap mp\"&gt;\r\n  &lt;Identity Name=\"1xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\" Version=\"1.0.0.0\" Publisher=\"CN=User\" \/&gt;\r\n  &lt;mp:PhoneIdentity PhoneProductId=\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\" PhonePublisherId=\"00000000-0000-0000-0000-000000000000\" \/&gt;\r\n  &lt;Properties&gt;\r\n    &lt;DisplayName&gt;Application&lt;\/DisplayName&gt;\r\n    &lt;PublisherDisplayName&gt;User&lt;\/PublisherDisplayName&gt;\r\n    &lt;Logo&gt;images\\storelogo.png&lt;\/Logo&gt;\r\n  &lt;\/Properties&gt;\r\n  &lt;Dependencies&gt;\r\n    &lt;TargetDeviceFamily Name=\"Windows.Universal\" MinVersion=\"10.0.0.0\" MaxVersionTested=\"10.0.0.0\" \/&gt;\r\n  &lt;\/Dependencies&gt;\r\n  &lt;Resources&gt;\r\n    &lt;Resource Language=\"x-generate\" \/&gt;\r\n  &lt;\/Resources&gt;\r\n  &lt;Applications&gt;\r\n    &lt;Application Id=\"App\" StartPage=\"ms-appx-web:\/\/\/index.html\"&gt;\r\n      &lt;uap:VisualElements DisplayName=\"MyApp\" Description=\"My App Description\" BackgroundColor=\"transparent\" Square150x150Logo=\"images\\Square150x150Logo.png\" Square44x44Logo=\"images\\Square44x44Logo.png\"&gt;\r\n        &lt;uap:DefaultTile Wide310x150Logo=\"images\\Wide310x150Logo.png\"&gt;\r\n        &lt;\/uap:DefaultTile&gt;\r\n        &lt;uap:SplashScreen Image=\"images\\splashscreen.png\" \/&gt;\r\n      &lt;\/uap:VisualElements&gt;\r\n      &lt;uap:ApplicationContentUriRules&gt;\r\n        &lt;uap:Rule Match=\"ms-appx-web:\/\/\/\" Type=\"include\" WindowsRuntimeAccess=\"all\" \/&gt;\r\n      &lt;\/uap:ApplicationContentUriRules&gt;\r\n    &lt;\/Application&gt;\r\n  &lt;\/Applications&gt;\r\n  &lt;Capabilities&gt;\r\n    &lt;Capability Name=\"internetClient\" \/&gt;\r\n  &lt;\/Capabilities&gt;\r\n&lt;\/Package&gt;<\/pre>\n<p>Quick and easy..<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently ported one of my java script projects to Windows store app and got the error as following CSP14321: Resource violated directive &#8216;script-src ms-appx: &#8216;unsafe-eval&#8217; blob:&#8217; in Host Defined Policy: inline script, in ms-appx:\/\/13bdc914-5111-4c95-a5e6-82029c5105ec\/index.html at line 21 column 12. Resource will be blocked. If you have something like the following, it won&#8217;t work &lt;a href=&#8221;javascript:void(0)&#8221; id=&#8221;somelink&#8221; onclick=&#8221;callMethod();&#8221;&gt;Link&lt;\/a&gt; Since I was using jQuery in the project, I simply used\u00a0jQuery to bind click event to the element $(&#8220;#somelink&#8221;).click(function () { callMethod(); }); and Voila, everything works but I had many pages which had this reference and I had to make this change to all pages. After some research I found that there is an alternate way which is much faster to change. By default\u00a0ms-appx:\/\/\/\u00a0protocol is used in store apps to fetch the content. For web apps specify a specific protocal\u00a0ms-appx-web which is then used for the app. This can be done[&#8230;]<\/p>\n","protected":false},"author":5,"featured_media":1540,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,23,24,17,21],"tags":[],"class_list":["post-833","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","category-html","category-javascript","category-jquery","category-windows-store-app"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/posts\/833","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/comments?post=833"}],"version-history":[{"count":2,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/posts\/833\/revisions"}],"predecessor-version":[{"id":836,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/posts\/833\/revisions\/836"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/media\/1540"}],"wp:attachment":[{"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/media?parent=833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/categories?post=833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.netexl.com\/blog\/wp-json\/wp\/v2\/tags?post=833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}