Skip to content

Commit e0262d7

Browse files
951648: Sample for ContentSecurityPolicy
1 parent bc50676 commit e0262d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+363585
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Web;
2+
using System.Web.Optimization;
3+
4+
namespace ContentSecurityPolicy
5+
{
6+
public class BundleConfig
7+
{
8+
// For more information on bundling, visit https://go.microsoft.com/fwlink/?LinkId=301862
9+
public static void RegisterBundles(BundleCollection bundles)
10+
{
11+
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
12+
"~/Scripts/jquery-{version}.js"));
13+
14+
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
15+
"~/Scripts/jquery.validate*"));
16+
17+
// Use the development version of Modernizr to develop with and learn from. Then, when you're
18+
// ready for production, use the build tool at https://modernizr.com to pick only the tests you need.
19+
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
20+
"~/Scripts/modernizr-*"));
21+
22+
bundles.Add(new Bundle("~/bundles/bootstrap").Include(
23+
"~/Scripts/bootstrap.js"));
24+
25+
bundles.Add(new StyleBundle("~/Content/css").Include(
26+
"~/Content/bootstrap.css",
27+
"~/Content/site.css"));
28+
}
29+
}
30+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Web;
2+
using System.Web.Mvc;
3+
4+
namespace ContentSecurityPolicy
5+
{
6+
public class FilterConfig
7+
{
8+
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
9+
{
10+
filters.Add(new HandleErrorAttribute());
11+
}
12+
}
13+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using System.Web.Mvc;
6+
using System.Web.Routing;
7+
8+
namespace ContentSecurityPolicy
9+
{
10+
public class RouteConfig
11+
{
12+
public static void RegisterRoutes(RouteCollection routes)
13+
{
14+
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
15+
16+
routes.MapRoute(
17+
name: "Default",
18+
url: "{controller}/{action}/{id}",
19+
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
20+
);
21+
}
22+
}
23+
}

ContentSecurityPolicy/ContentSecurityPolicy.csproj

Lines changed: 331 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<UseIISExpress>true</UseIISExpress>
5+
<Use64BitIISExpress />
6+
<IISExpressSSLPort>44399</IISExpressSSLPort>
7+
<IISExpressAnonymousAuthentication />
8+
<IISExpressWindowsAuthentication />
9+
<IISExpressUseClassicPipelineMode />
10+
<UseGlobalApplicationHostFile />
11+
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
12+
</PropertyGroup>
13+
<ProjectExtensions>
14+
<VisualStudio>
15+
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
16+
<WebProjectProperties>
17+
<StartPageUrl>
18+
</StartPageUrl>
19+
<StartAction>CurrentPage</StartAction>
20+
<AspNetDebugging>True</AspNetDebugging>
21+
<SilverlightDebugging>False</SilverlightDebugging>
22+
<NativeDebugging>False</NativeDebugging>
23+
<SQLDebugging>False</SQLDebugging>
24+
<ExternalProgram>
25+
</ExternalProgram>
26+
<StartExternalURL>
27+
</StartExternalURL>
28+
<StartCmdLineArguments>
29+
</StartCmdLineArguments>
30+
<StartWorkingDirectory>
31+
</StartWorkingDirectory>
32+
<EnableENC>True</EnableENC>
33+
<AlwaysStartWebServerOnDebug>False</AlwaysStartWebServerOnDebug>
34+
</WebProjectProperties>
35+
</FlavorProperties>
36+
</VisualStudio>
37+
</ProjectExtensions>
38+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35527.113 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ContentSecurityPolicy", "ContentSecurityPolicy.csproj", "{E774BE14-799E-49E5-A1E2-4A89B3B4BF8A}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{E774BE14-799E-49E5-A1E2-4A89B3B4BF8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E774BE14-799E-49E5-A1E2-4A89B3B4BF8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E774BE14-799E-49E5-A1E2-4A89B3B4BF8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{E774BE14-799E-49E5-A1E2-4A89B3B4BF8A}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using System.Web.Mvc;
6+
7+
namespace ContentSecurityPolicy.Controllers
8+
{
9+
public class HomeController : Controller
10+
{
11+
public ActionResult Index()
12+
{
13+
return View();
14+
}
15+
16+
public ActionResult About()
17+
{
18+
ViewBag.Message = "Your application description page.";
19+
20+
return View();
21+
}
22+
23+
public ActionResult Contact()
24+
{
25+
ViewBag.Message = "Your contact page.";
26+
27+
return View();
28+
}
29+
}
30+
}

ContentSecurityPolicy/Global.asax

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%@ Application Codebehind="Global.asax.cs" Inherits="ContentSecurityPolicy.MvcApplication" Language="C#" %>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using System.Web.Mvc;
6+
using System.Web.Optimization;
7+
using System.Web.Routing;
8+
9+
namespace ContentSecurityPolicy
10+
{
11+
public class MvcApplication : System.Web.HttpApplication
12+
{
13+
protected void Application_Start()
14+
{
15+
AreaRegistration.RegisterAllAreas();
16+
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
17+
RouteConfig.RegisterRoutes(RouteTable.Routes);
18+
BundleConfig.RegisterBundles(BundleTable.Bundles);
19+
}
20+
}
21+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("ContentSecurityPolicy")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("ContentSecurityPolicy")]
13+
[assembly: AssemblyCopyright("Copyright © 2025")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("62122dcd-f6c5-4bd4-a5bb-e4f9c66a7cfc")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Revision and Build Numbers
33+
// by using the '*' as shown below:
34+
[assembly: AssemblyVersion("1.0.0.0")]
35+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)