-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalize transaction names for ASP.NET Full Framework (#973)
This commit normalizes the transaction name for ASP.NET MVC Full Framework to use the convention of <HTTP method> <area>/<controller>/<action> [<param>*] which aligns with the convention used in ASP.NET Core transaction names. The transaction name is determined from the RouteData values. - set unknown route only when the route data did not end up routing to a controller action. This is determined by looking for a 404 HttpException coming from System.Web.Mvc. - Add webforms page, routed webforms page, web api controller, and area controller, to assert transaction name in each case. - Integration tests introduce an MVC area with a HomeController and Index action, to assert that the area route datatoken is taken into account. Without taking into account the area, same named controller actions in areas would end up aggregrated under the same transaction name. Closes #201
- Loading branch information
Showing
49 changed files
with
969 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
sample/AspNetFullFrameworkSampleApp/App_Start/WebApiConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Licensed to Elasticsearch B.V under | ||
// one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information | ||
|
||
using System.Linq; | ||
using System.Web.Http; | ||
|
||
namespace AspNetFullFrameworkSampleApp | ||
{ | ||
public static class WebApiConfig | ||
{ | ||
public static void Register(HttpConfiguration configuration) | ||
{ | ||
// remove xml support | ||
var appXmlType = configuration.Formatters.XmlFormatter.SupportedMediaTypes | ||
.FirstOrDefault(t => t.MediaType == "application/xml"); | ||
configuration.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
sample/AspNetFullFrameworkSampleApp/Areas/MyArea/Controllers/HomeController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Licensed to Elasticsearch B.V under | ||
// one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information | ||
|
||
using System.Web.Mvc; | ||
|
||
namespace AspNetFullFrameworkSampleApp.Areas.MyArea.Controllers | ||
{ | ||
public class HomeController : Controller | ||
{ | ||
internal const string HomePageRelativePath = "MyArea/Home"; | ||
|
||
public ActionResult Index() => View(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
sample/AspNetFullFrameworkSampleApp/Areas/MyArea/MyAreaRegistration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Licensed to Elasticsearch B.V under | ||
// one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information | ||
|
||
using System.Web.Mvc; | ||
|
||
namespace AspNetFullFrameworkSampleApp.Areas.MyArea | ||
{ | ||
public class MyAreaRegistration : AreaRegistration | ||
{ | ||
public override void RegisterArea(AreaRegistrationContext context) => | ||
context.MapRoute("MyArea_Default", | ||
"MyArea/{controller}/{action}/{id}", | ||
new { action = "Index", id = UrlParameter.Optional }, | ||
new[] { "AspNetFullFrameworkSampleApp.Areas.MyArea.Controllers" }); | ||
|
||
public override string AreaName => "MyArea"; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
sample/AspNetFullFrameworkSampleApp/Areas/MyArea/Views/Home/Index.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
@{ | ||
ViewBag.Title = "My Area Home Page"; | ||
} | ||
|
||
<div class="jumbotron"> | ||
<h1>ASP.NET</h1> | ||
<p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p> | ||
<p> | ||
<a href="https://asp.net" class="btn btn-primary btn-lg">Learn more »</a> | ||
</p> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-md-4"> | ||
<h2>Getting started</h2> | ||
<p> | ||
ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that | ||
enables a clean separation of concerns and gives you full control over markup | ||
for enjoyable, agile development. | ||
</p> | ||
<p> | ||
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkId=301865">Learn more »</a> | ||
</p> | ||
</div> | ||
<div class="col-md-4"> | ||
<h2>Get more libraries</h2> | ||
<p>NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.</p> | ||
<p> | ||
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkId=301866">Learn more »</a> | ||
</p> | ||
</div> | ||
<div class="col-md-4"> | ||
<h2>Web Hosting</h2> | ||
<p>You can easily find a web hosting company that offers the right mix of features and price for your applications.</p> | ||
<p> | ||
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkId=301867">Learn more »</a> | ||
</p> | ||
</div> | ||
</div> |
43 changes: 43 additions & 0 deletions
43
sample/AspNetFullFrameworkSampleApp/Areas/MyArea/Web.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0"?> | ||
|
||
<configuration> | ||
<configSections> | ||
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> | ||
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> | ||
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> | ||
</sectionGroup> | ||
</configSections> | ||
|
||
<system.web.webPages.razor> | ||
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> | ||
<pages pageBaseType="System.Web.Mvc.WebViewPage"> | ||
<namespaces> | ||
<add namespace="System.Web.Mvc" /> | ||
<add namespace="System.Web.Mvc.Ajax" /> | ||
<add namespace="System.Web.Mvc.Html" /> | ||
<add namespace="System.Web.Optimization"/> | ||
<add namespace="System.Web.Routing" /> | ||
<add namespace="AspNetFullFrameworkSampleApp" /> | ||
</namespaces> | ||
</pages> | ||
</system.web.webPages.razor> | ||
|
||
<appSettings> | ||
<add key="webpages:Enabled" value="false" /> | ||
</appSettings> | ||
|
||
<system.webServer> | ||
<handlers> | ||
<remove name="BlockViewHandler"/> | ||
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" /> | ||
</handlers> | ||
</system.webServer> | ||
|
||
<system.web> | ||
<compilation> | ||
<assemblies> | ||
<add assembly="System.Web.Mvc, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> | ||
</assemblies> | ||
</compilation> | ||
</system.web> | ||
</configuration> |
3 changes: 3 additions & 0 deletions
3
sample/AspNetFullFrameworkSampleApp/Areas/MyArea/_ViewStart.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@{ | ||
Layout = "~/Views/Shared/_Layout.cshtml"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.