diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9e83863 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ + +bin +Bin +obj +sql +*.user +*.suo +packages +_ReSharper* +dist +output +build +*.dbmdl + +*~ + +*.swp +TestResult.xml + + +*.dropbox +desktop.ini +*.publish.xml +*.refactorlog + +info +nugetPacks \ No newline at end of file diff --git a/ElmahErrorFilterApp/.nuget/NuGet.Config b/ElmahErrorFilterApp/.nuget/NuGet.Config new file mode 100644 index 0000000..67f8ea0 --- /dev/null +++ b/ElmahErrorFilterApp/.nuget/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ElmahErrorFilterApp/.nuget/NuGet.exe b/ElmahErrorFilterApp/.nuget/NuGet.exe new file mode 100644 index 0000000..34ad49b Binary files /dev/null and b/ElmahErrorFilterApp/.nuget/NuGet.exe differ diff --git a/ElmahErrorFilterApp/.nuget/NuGet.targets b/ElmahErrorFilterApp/.nuget/NuGet.targets new file mode 100644 index 0000000..25380fe --- /dev/null +++ b/ElmahErrorFilterApp/.nuget/NuGet.targets @@ -0,0 +1,52 @@ + + + + $(MSBuildProjectDirectory)\..\ + $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) + $(NuGetToolsPath)\nuget.exe + $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) + $([System.IO.Path]::Combine($(SolutionDir), "packages")) + $(TargetDir.Trim('\\')) + + + "" + + + false + + + false + + + "$(NuGetExePath)" install "$(PackagesConfig)" -source $(PackageSources) -o "$(PackagesDir)" + "$(NuGetExePath)" pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols + + + + RestorePackages; + $(BuildDependsOn); + + + + + $(BuildDependsOn); + BuildPackage; + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ElmahErrorFilterApp/ElmahErrorFilterApp.sln b/ElmahErrorFilterApp/ElmahErrorFilterApp.sln new file mode 100644 index 0000000..86b6123 --- /dev/null +++ b/ElmahErrorFilterApp/ElmahErrorFilterApp.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElmahErrorFilterApp", "src\ElmahErrorFilterApp\ElmahErrorFilterApp.csproj", "{2847EEC8-0085-4561-BEAF-26250230A642}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{86AD020B-559A-4625-A084-0A86BBFEB5AC}" + ProjectSection(SolutionItems) = preProject + .nuget\NuGet.exe = .nuget\NuGet.exe + .nuget\NuGet.targets = .nuget\NuGet.targets + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2847EEC8-0085-4561-BEAF-26250230A642}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2847EEC8-0085-4561-BEAF-26250230A642}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2847EEC8-0085-4561-BEAF-26250230A642}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2847EEC8-0085-4561-BEAF-26250230A642}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Controllers/ValuesController.cs b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Controllers/ValuesController.cs new file mode 100644 index 0000000..ab19c52 --- /dev/null +++ b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Controllers/ValuesController.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Web.Http; + +namespace ElmahErrorFilterApp.Controllers { + + public class ValuesController : ApiController { + + // GET /api/values + public IEnumerable Get() { + return new string[] { "value1", "value2" }; + } + + // GET /api/values/5 + public string Get(int id) { + throw new NotImplementedException(); + } + + // POST /api/values + public void Post(string value) + { + } + + // PUT /api/values/5 + public void Put(int id, string value) + { + } + + // DELETE /api/values/5 + public void Delete(int id) + { + } + } +} \ No newline at end of file diff --git a/ElmahErrorFilterApp/src/ElmahErrorFilterApp/ElmahErrorFilterApp.csproj b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/ElmahErrorFilterApp.csproj new file mode 100644 index 0000000..f574fd0 --- /dev/null +++ b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/ElmahErrorFilterApp.csproj @@ -0,0 +1,144 @@ + + + + Debug + AnyCPU + + + 2.0 + {2847EEC8-0085-4561-BEAF-26250230A642} + {E3E379DF-F4C6-4180-9B81-6769533ABE47};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + ElmahErrorFilterApp + ElmahErrorFilterApp + v4.0 + false + false + ..\..\ + true + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + ..\..\packages\elmah.corelibrary.1.2.1\lib\Elmah.dll + + + + True + ..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + + + + + + + True + ..\..\packages\System.Json.4.0.20126.16343\lib\net40\System.Json.dll + + + True + ..\..\packages\System.Net.Http.2.0.20126.16343\lib\net40\System.Net.Http.dll + + + True + ..\..\packages\System.Net.Http.Formatting.4.0.20126.16343\lib\net40\System.Net.Http.Formatting.dll + + + True + ..\..\packages\System.Net.Http.2.0.20126.16343\lib\net40\System.Net.Http.WebRequest.dll + + + + + + + + True + ..\..\packages\AspNetWebApi.Core.4.0.20126.16343\lib\net40\System.Web.Http.dll + + + True + ..\..\packages\System.Web.Http.Common.4.0.20126.16343\lib\net40\System.Web.Http.Common.dll + + + True + ..\..\packages\AspNetWebApi.4.0.20126.16343\lib\net40\System.Web.Http.WebHost.dll + + + + + + + + + + + + Global.asax + + + + + + + + + Web.config + + + Web.config + + + + + + + + + + + + + + + + + False + True + 6534 + / + + + False + False + + + False + + + + + + \ No newline at end of file diff --git a/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Global.asax b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Global.asax new file mode 100644 index 0000000..7b5e83b --- /dev/null +++ b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Global.asax @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.cs" Inherits="ElmahErrorFilterApp.WebApiApplication" Language="C#" %> diff --git a/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Global.asax.cs b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Global.asax.cs new file mode 100644 index 0000000..843c52d --- /dev/null +++ b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Global.asax.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Http; +using System.Web.Routing; +using ElmahErrorFilterApp.Infrastructure.Filters; + +namespace ElmahErrorFilterApp { + + // Note: For instructions on enabling IIS6 or IIS7 classic mode, + // visit http://go.microsoft.com/?LinkId=9394801 + + public class WebApiApplication : System.Web.HttpApplication { + + protected void Application_Start() { + + Configure(System.Web.Http.GlobalConfiguration.Configuration); + } + + private void Configure(HttpConfiguration httpConfiguration) { + + httpConfiguration.Filters.Add(new ElmahErrorAttribute()); + + httpConfiguration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Never; + + httpConfiguration.Routes.MapHttpRoute( + name: "DefaultApi", + routeTemplate: "api/{controller}/{id}", + defaults: new { id = RouteParameter.Optional } + ); + } + } +} \ No newline at end of file diff --git a/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Infrastructure/Filters/ElmahErrorAttribute.cs b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Infrastructure/Filters/ElmahErrorAttribute.cs new file mode 100644 index 0000000..125cbc3 --- /dev/null +++ b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Infrastructure/Filters/ElmahErrorAttribute.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace ElmahErrorFilterApp.Infrastructure.Filters { + + public class ElmahErrorAttribute : + System.Web.Http.Filters.ExceptionFilterAttribute { + + public override void OnException( + System.Web.Http.Filters.HttpActionExecutedContext actionExecutedContext) { + + if(actionExecutedContext.Exception != null) + Elmah.ErrorSignal.FromCurrentContext().Raise(actionExecutedContext.Exception); + + base.OnException(actionExecutedContext); + } + } +} \ No newline at end of file diff --git a/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Properties/AssemblyInfo.cs b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..86967b2 --- /dev/null +++ b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ElmahErrorFilterApp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Toshiba")] +[assembly: AssemblyProduct("ElmahErrorFilterApp")] +[assembly: AssemblyCopyright("Copyright © Toshiba 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("34164cab-c523-43a9-860c-e2b222834d8b")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Web.Debug.config b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Web.Debug.config new file mode 100644 index 0000000..3e2a97c --- /dev/null +++ b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Web.Debug.config @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Web.Release.config b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Web.Release.config new file mode 100644 index 0000000..9fd481f --- /dev/null +++ b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Web.Release.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Web.config b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Web.config new file mode 100644 index 0000000..7e77559 --- /dev/null +++ b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/Web.config @@ -0,0 +1,38 @@ + + + + + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ElmahErrorFilterApp/src/ElmahErrorFilterApp/packages.config b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/packages.config new file mode 100644 index 0000000..cb94e42 --- /dev/null +++ b/ElmahErrorFilterApp/src/ElmahErrorFilterApp/packages.config @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file