Skip to content

Commit 33bdec0

Browse files
committed
Created an AutoFac enabled ASP MVC 4 Demo project.
1 parent 64807c6 commit 33bdec0

18 files changed

+579
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Web.Mvc;
2+
3+
namespace DevTrends.MvcDonutCaching.Demo
4+
{
5+
public class FilterConfig
6+
{
7+
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
8+
{
9+
filters.Add(new HandleErrorAttribute());
10+
}
11+
}
12+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Web.Mvc;
2+
using System.Web.Routing;
3+
4+
namespace DevTrends.MvcDonutCaching.Demo
5+
{
6+
public class RouteConfig
7+
{
8+
public static void RegisterRoutes(RouteCollection routes)
9+
{
10+
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
11+
12+
routes.MapRoute(
13+
name: "Default",
14+
url: "{controller}/{action}/{id}",
15+
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
16+
);
17+
}
18+
}
19+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using System.Web.Mvc;
6+
7+
namespace DevTrends.MvcDonutCaching.Demo.Controllers
8+
{
9+
public class HomeController : Controller
10+
{
11+
//
12+
// GET: /Home/
13+
public ActionResult Index()
14+
{
15+
return View();
16+
}
17+
}
18+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
// Uncomment this class to provide custom runtime policy for Glimpse
3+
4+
using Glimpse.AspNet.Extensions;
5+
using Glimpse.Core.Extensibility;
6+
7+
namespace DevTrends.MvcDonutCaching.Demo
8+
{
9+
public class GlimpseSecurityPolicy:IRuntimePolicy
10+
{
11+
public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
12+
{
13+
// You can perform a check like the one below to control Glimpse's permissions within your application.
14+
// More information about RuntimePolicies can be found at http://getglimpse.com/Help/Custom-Runtime-Policy
15+
// var httpContext = policyContext.GetHttpContext();
16+
// if (!httpContext.User.IsInRole("Administrator"))
17+
// {
18+
// return RuntimePolicy.Off;
19+
// }
20+
21+
return RuntimePolicy.On;
22+
}
23+
24+
public RuntimeEvent ExecuteOn
25+
{
26+
get { return RuntimeEvent.EndRequest; }
27+
}
28+
}
29+
}
30+
*/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%@ Application Codebehind="Global.asax.cs" Inherits="DevTrends.MvcDonutCaching.Demo.MvcApplication" Language="C#" %>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System.Web.Mvc;
2+
using System.Web.Routing;
3+
using Autofac;
4+
using Autofac.Integration.Mvc;
5+
6+
namespace DevTrends.MvcDonutCaching.Demo
7+
{
8+
public class MvcApplication : System.Web.HttpApplication
9+
{
10+
public IContainer Container
11+
{
12+
get;
13+
set;
14+
}
15+
16+
protected void Application_Start()
17+
{
18+
AreaRegistration.RegisterAllAreas();
19+
20+
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
21+
RouteConfig.RegisterRoutes(RouteTable.Routes);
22+
23+
Container = RegisterAutofac();
24+
}
25+
26+
private static IContainer RegisterAutofac()
27+
{
28+
var builder = new ContainerBuilder();
29+
builder.RegisterControllers(typeof(MvcApplication).Assembly);
30+
builder.RegisterFilterProvider();
31+
builder.RegisterModelBinderProvider();
32+
33+
var container = builder.Build();
34+
container.ActivateGlimpse();
35+
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
36+
37+
return container;
38+
}
39+
}
40+
}
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProductVersion>
8+
</ProductVersion>
9+
<SchemaVersion>2.0</SchemaVersion>
10+
<ProjectGuid>{2C31E962-9616-4292-9DB6-52E40CB07E19}</ProjectGuid>
11+
<ProjectTypeGuids>{E3E379DF-F4C6-4180-9B81-6769533ABE47};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
12+
<OutputType>Library</OutputType>
13+
<AppDesignerFolder>Properties</AppDesignerFolder>
14+
<RootNamespace>DevTrends.MvcDonutCaching.Demo</RootNamespace>
15+
<AssemblyName>DevTrends.MvcDonutCaching.Demo</AssemblyName>
16+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
17+
<MvcBuildViews>false</MvcBuildViews>
18+
<UseIISExpress>true</UseIISExpress>
19+
<IISExpressSSLPort />
20+
<IISExpressAnonymousAuthentication />
21+
<IISExpressWindowsAuthentication />
22+
<IISExpressUseClassicPipelineMode />
23+
<TargetFrameworkProfile />
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
26+
<DebugSymbols>true</DebugSymbols>
27+
<DebugType>full</DebugType>
28+
<Optimize>false</Optimize>
29+
<OutputPath>bin\</OutputPath>
30+
<DefineConstants>DEBUG;TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
35+
<DebugType>pdbonly</DebugType>
36+
<Optimize>true</Optimize>
37+
<OutputPath>bin\</OutputPath>
38+
<DefineConstants>TRACE</DefineConstants>
39+
<ErrorReport>prompt</ErrorReport>
40+
<WarningLevel>4</WarningLevel>
41+
</PropertyGroup>
42+
<ItemGroup>
43+
<Reference Include="Autofac">
44+
<HintPath>..\packages\Autofac.3.1.1\lib\net40\Autofac.dll</HintPath>
45+
</Reference>
46+
<Reference Include="Autofac.Integration.Mvc">
47+
<HintPath>..\packages\Autofac.Mvc4.3.1.0\lib\net40\Autofac.Integration.Mvc.dll</HintPath>
48+
</Reference>
49+
<Reference Include="Glimpse.AspNet, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL">
50+
<SpecificVersion>False</SpecificVersion>
51+
<HintPath>..\packages\Glimpse.AspNet.1.4.1\lib\net40\Glimpse.AspNet.dll</HintPath>
52+
</Reference>
53+
<Reference Include="Glimpse.Autofac">
54+
<HintPath>..\packages\Glimpse.Autofac.0.2.4\lib\net40\Glimpse.Autofac.dll</HintPath>
55+
</Reference>
56+
<Reference Include="Glimpse.Core">
57+
<HintPath>..\packages\Glimpse.1.6.1\lib\net40\Glimpse.Core.dll</HintPath>
58+
</Reference>
59+
<Reference Include="Glimpse.Mvc4">
60+
<HintPath>..\packages\Glimpse.Mvc4.1.3.3\lib\net40\Glimpse.Mvc4.dll</HintPath>
61+
</Reference>
62+
<Reference Include="Microsoft.CSharp" />
63+
<Reference Include="Microsoft.Web.Mvc.FixedDisplayModes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
64+
<SpecificVersion>False</SpecificVersion>
65+
<HintPath>..\packages\Microsoft.AspNet.Mvc.FixedDisplayModes.1.0.1\lib\net40\Microsoft.Web.Mvc.FixedDisplayModes.dll</HintPath>
66+
</Reference>
67+
<Reference Include="System" />
68+
<Reference Include="System.Drawing" />
69+
<Reference Include="System.Web.DynamicData" />
70+
<Reference Include="System.Web.ApplicationServices" />
71+
<Reference Include="System.ComponentModel.DataAnnotations" />
72+
<Reference Include="System.Web.Extensions" />
73+
<Reference Include="System.Web" />
74+
<Reference Include="System.Web.Abstractions" />
75+
<Reference Include="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
76+
<Private>True</Private>
77+
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.Helpers.dll</HintPath>
78+
</Reference>
79+
<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
80+
<Private>True</Private>
81+
<HintPath>..\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll</HintPath>
82+
</Reference>
83+
<Reference Include="System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
84+
<Private>True</Private>
85+
<HintPath>..\packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll</HintPath>
86+
</Reference>
87+
<Reference Include="System.Web.Routing" />
88+
<Reference Include="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
89+
<Private>True</Private>
90+
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.dll</HintPath>
91+
</Reference>
92+
<Reference Include="System.Web.WebPages.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
93+
<Private>True</Private>
94+
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Deployment.dll</HintPath>
95+
</Reference>
96+
<Reference Include="System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
97+
<Private>True</Private>
98+
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll</HintPath>
99+
</Reference>
100+
<Reference Include="System.Xml" />
101+
<Reference Include="System.Configuration" />
102+
<Reference Include="System.Web.Services" />
103+
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
104+
<Private>True</Private>
105+
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
106+
</Reference>
107+
<Reference Include="System.Xml.Linq" />
108+
</ItemGroup>
109+
<ItemGroup>
110+
<Compile Include="Controllers\HomeController.cs" />
111+
<Compile Include="GlimpseSecurityPolicy.cs" />
112+
<Compile Include="Global.asax.cs">
113+
<DependentUpon>Global.asax</DependentUpon>
114+
</Compile>
115+
<Compile Include="Properties\AssemblyInfo.cs" />
116+
</ItemGroup>
117+
<ItemGroup>
118+
<Compile Include="App_Start\FilterConfig.cs" />
119+
<Compile Include="App_Start\RouteConfig.cs" />
120+
<Content Include="Global.asax" />
121+
<Content Include="Web.config">
122+
<SubType>Designer</SubType>
123+
</Content>
124+
<Content Include="Web.Debug.config">
125+
<DependentUpon>Web.config</DependentUpon>
126+
</Content>
127+
<Content Include="Web.Release.config">
128+
<DependentUpon>Web.config</DependentUpon>
129+
</Content>
130+
<Content Include="Views\Web.config" />
131+
</ItemGroup>
132+
<ItemGroup>
133+
<Folder Include="App_Data\" />
134+
<Folder Include="Models\" />
135+
</ItemGroup>
136+
<ItemGroup>
137+
<Content Include="packages.config">
138+
<SubType>Designer</SubType>
139+
</Content>
140+
</ItemGroup>
141+
<ItemGroup>
142+
<ProjectReference Include="..\DevTrends.MvcDonutCaching\MvcDonutCaching.csproj">
143+
<Project>{854e90c7-8320-4eb6-a286-24a8ee5ebe9b}</Project>
144+
<Name>MvcDonutCaching</Name>
145+
</ProjectReference>
146+
</ItemGroup>
147+
<ItemGroup>
148+
<Content Include="Views\Home\Index.cshtml" />
149+
</ItemGroup>
150+
<ItemGroup>
151+
<Content Include="Views\_ViewStart.cshtml" />
152+
</ItemGroup>
153+
<ItemGroup>
154+
<Content Include="Views\Shared\_Layout.cshtml" />
155+
</ItemGroup>
156+
<PropertyGroup>
157+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
158+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
159+
</PropertyGroup>
160+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
161+
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
162+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
163+
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
164+
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
165+
</Target>
166+
<ProjectExtensions>
167+
<VisualStudio>
168+
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
169+
<WebProjectProperties>
170+
<UseIIS>True</UseIIS>
171+
<AutoAssignPort>True</AutoAssignPort>
172+
<DevelopmentServerPort>0</DevelopmentServerPort>
173+
<DevelopmentServerVPath>/</DevelopmentServerVPath>
174+
<IISUrl>http://localhost:2914/</IISUrl>
175+
<NTLMAuthentication>False</NTLMAuthentication>
176+
<UseCustomServer>False</UseCustomServer>
177+
<CustomServerUrl>
178+
</CustomServerUrl>
179+
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
180+
</WebProjectProperties>
181+
</FlavorProperties>
182+
</VisualStudio>
183+
</ProjectExtensions>
184+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
185+
Other similar extension points exist, see Microsoft.Common.targets.
186+
<Target Name="BeforeBuild">
187+
</Target>
188+
<Target Name="AfterBuild">
189+
</Target> -->
190+
</Project>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=App_005FStart/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
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+
// Les informations générales relatives à un assembly dépendent de
6+
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
7+
// associées à un assembly.
8+
[assembly: AssemblyTitle("MvcDonutCaching.Demo")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("MvcDonutCaching.Demo")]
13+
[assembly: AssemblyCopyright("Copyright © 2013")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
18+
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
19+
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
20+
[assembly: ComVisible(false)]
21+
22+
// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
23+
[assembly: Guid("25ab36b3-64e5-4c8f-9216-dabdb48eac60")]
24+
25+
// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
26+
//
27+
// Version principale
28+
// Version secondaire
29+
// Numéro de build
30+
// Révision
31+
//
32+
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de révision et de build par défaut
33+
// en utilisant '*', comme indiqué ci-dessous :
34+
[assembly: AssemblyVersion("1.0.0.0")]
35+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@{
2+
ViewBag.Title = "title";
3+
}
4+
5+
<h2>@ViewBag.Title</h2>

0 commit comments

Comments
 (0)