Skip to content

Commit 73ba4ae

Browse files
committed
Reproduction code for Aspnet Api Version Issue 130: dotnet/aspnet-api-versioning#130
1 parent 9eb6b4e commit 73ba4ae

File tree

120 files changed

+47060
-0
lines changed

Some content is hidden

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

120 files changed

+47060
-0
lines changed

ApiVerIssue/ApiVerIssue.sln

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26430.6
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SwagApiMvcTest", "SwagApiMvcTest\SwagApiMvcTest.csproj", "{09BD4F4A-D408-4C8B-9F02-B98BF0762BD9}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvcApiTest", "MvcApiTest\MvcApiTest.csproj", "{7EA1601F-D222-44EA-9896-6C251089D043}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{09BD4F4A-D408-4C8B-9F02-B98BF0762BD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{09BD4F4A-D408-4C8B-9F02-B98BF0762BD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{09BD4F4A-D408-4C8B-9F02-B98BF0762BD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{09BD4F4A-D408-4C8B-9F02-B98BF0762BD9}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{7EA1601F-D222-44EA-9896-6C251089D043}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{7EA1601F-D222-44EA-9896-6C251089D043}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{7EA1601F-D222-44EA-9896-6C251089D043}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{7EA1601F-D222-44EA-9896-6C251089D043}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
EndGlobal

ApiVerIssue/MvcApiTest/.bowerrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "wwwroot/lib"
3+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
7+
namespace MvcApiTest.Controllers {
8+
[ApiVersionNeutral]
9+
[Route("")]
10+
[Route("home")]
11+
public class HomeController : Controller {
12+
[Route("")]
13+
[Route("index")]
14+
public IActionResult Index() {
15+
return View();
16+
}
17+
18+
[Route("about")]
19+
public IActionResult About() {
20+
ViewData["Message"] = "Your application description page.";
21+
22+
return View();
23+
}
24+
25+
[Route("contact")]
26+
public IActionResult Contact() {
27+
ViewData["Message"] = "Your contact page.";
28+
29+
return View();
30+
}
31+
32+
[Route("error")]
33+
public IActionResult Error() {
34+
return View();
35+
}
36+
}
37+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp1.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
<PropertyGroup>
8+
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
9+
</PropertyGroup>
10+
<ItemGroup>
11+
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
12+
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
13+
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
14+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="1.1.0-rc1" />
15+
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
16+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
17+
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.2" />
18+
</ItemGroup>
19+
<ItemGroup>
20+
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
21+
</ItemGroup>
22+
<ItemGroup>
23+
<Content Update="appsettings.Development.json">
24+
<DependentUpon>appsettings.json</DependentUpon>
25+
</Content>
26+
</ItemGroup>
27+
<ItemGroup>
28+
<None Update=".bowerrc">
29+
<DependentUpon>bower.json</DependentUpon>
30+
</None>
31+
</ItemGroup>
32+
33+
</Project>

ApiVerIssue/MvcApiTest/Program.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.IO;
2+
using Microsoft.AspNetCore.Hosting;
3+
4+
namespace MvcApiTest {
5+
public class Program
6+
{
7+
public static void Main(string[] args)
8+
{
9+
var host = new WebHostBuilder()
10+
.UseKestrel()
11+
.UseContentRoot(Directory.GetCurrentDirectory())
12+
.UseIISIntegration()
13+
.UseStartup<Startup>()
14+
.UseApplicationInsights()
15+
.Build();
16+
17+
host.Run();
18+
}
19+
}
20+
}

ApiVerIssue/MvcApiTest/Startup.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.AspNetCore.Hosting;
3+
using Microsoft.Extensions.Configuration;
4+
using Microsoft.Extensions.DependencyInjection;
5+
using Microsoft.Extensions.Logging;
6+
7+
namespace MvcApiTest {
8+
public class Startup
9+
{
10+
public Startup(IHostingEnvironment env)
11+
{
12+
var builder = new ConfigurationBuilder()
13+
.SetBasePath(env.ContentRootPath)
14+
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
15+
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
16+
.AddEnvironmentVariables();
17+
Configuration = builder.Build();
18+
}
19+
20+
public IConfigurationRoot Configuration { get; }
21+
22+
// This method gets called by the runtime. Use this method to add services to the container.
23+
public void ConfigureServices(IServiceCollection services)
24+
{
25+
// Add framework services.
26+
services.AddMvc();
27+
services.AddApiVersioning();
28+
}
29+
30+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
31+
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
32+
{
33+
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
34+
loggerFactory.AddDebug();
35+
36+
if (env.IsDevelopment())
37+
{
38+
app.UseDeveloperExceptionPage();
39+
app.UseBrowserLink();
40+
}
41+
else
42+
{
43+
app.UseExceptionHandler("/Home/Error");
44+
}
45+
46+
app.UseStaticFiles();
47+
48+
app.UseMvc().UseApiVersioning();
49+
}
50+
}
51+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@{
2+
ViewData["Title"] = "About";
3+
}
4+
<h2>@ViewData["Title"].</h2>
5+
<h3>@ViewData["Message"]</h3>
6+
7+
<p>Use this area to provide additional information.</p>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@{
2+
ViewData["Title"] = "Contact";
3+
}
4+
<h2>@ViewData["Title"].</h2>
5+
<h3>@ViewData["Message"]</h3>
6+
7+
<address>
8+
One Microsoft Way<br />
9+
Redmond, WA 98052-6399<br />
10+
<abbr title="Phone">P:</abbr>
11+
425.555.0100
12+
</address>
13+
14+
<address>
15+
<strong>Support:</strong> <a href="mailto:[email protected]">Support@example.com</a><br />
16+
<strong>Marketing:</strong> <a href="mailto:[email protected]">Marketing@example.com</a>
17+
</address>
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
@{
2+
ViewData["Title"] = "Home Page";
3+
}
4+
5+
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="6000">
6+
<ol class="carousel-indicators">
7+
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
8+
<li data-target="#myCarousel" data-slide-to="1"></li>
9+
<li data-target="#myCarousel" data-slide-to="2"></li>
10+
<li data-target="#myCarousel" data-slide-to="3"></li>
11+
</ol>
12+
<div class="carousel-inner" role="listbox">
13+
<div class="item active">
14+
<img src="~/images/banner1.svg" alt="ASP.NET" class="img-responsive" />
15+
<div class="carousel-caption" role="option">
16+
<p>
17+
Learn how to build ASP.NET apps that can run anywhere.
18+
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525028&clcid=0x409">
19+
Learn More
20+
</a>
21+
</p>
22+
</div>
23+
</div>
24+
<div class="item">
25+
<img src="~/images/banner2.svg" alt="Visual Studio" class="img-responsive" />
26+
<div class="carousel-caption" role="option">
27+
<p>
28+
There are powerful new features in Visual Studio for building modern web apps.
29+
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525030&clcid=0x409">
30+
Learn More
31+
</a>
32+
</p>
33+
</div>
34+
</div>
35+
<div class="item">
36+
<img src="~/images/banner3.svg" alt="Package Management" class="img-responsive" />
37+
<div class="carousel-caption" role="option">
38+
<p>
39+
Bring in libraries from NuGet, Bower, and npm, and automate tasks using Grunt or Gulp.
40+
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525029&clcid=0x409">
41+
Learn More
42+
</a>
43+
</p>
44+
</div>
45+
</div>
46+
<div class="item">
47+
<img src="~/images/banner4.svg" alt="Microsoft Azure" class="img-responsive" />
48+
<div class="carousel-caption" role="option">
49+
<p>
50+
Learn how Microsoft's Azure cloud platform allows you to build, deploy, and scale web apps.
51+
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525027&clcid=0x409">
52+
Learn More
53+
</a>
54+
</p>
55+
</div>
56+
</div>
57+
</div>
58+
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
59+
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
60+
<span class="sr-only">Previous</span>
61+
</a>
62+
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
63+
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
64+
<span class="sr-only">Next</span>
65+
</a>
66+
</div>
67+
68+
<div class="row">
69+
<div class="col-md-3">
70+
<h2>Application uses</h2>
71+
<ul>
72+
<li>Sample pages using ASP.NET Core MVC</li>
73+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=518004">Bower</a> for managing client-side libraries</li>
74+
<li>Theming using <a href="https://go.microsoft.com/fwlink/?LinkID=398939">Bootstrap</a></li>
75+
</ul>
76+
</div>
77+
<div class="col-md-3">
78+
<h2>How to</h2>
79+
<ul>
80+
<li><a href="https://go.microsoft.com/fwlink/?LinkID=398600">Add a Controller and View</a></li>
81+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699315">Manage User Secrets using Secret Manager.</a></li>
82+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699316">Use logging to log a message.</a></li>
83+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699317">Add packages using NuGet.</a></li>
84+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699318">Add client packages using Bower.</a></li>
85+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699319">Target development, staging or production environment.</a></li>
86+
</ul>
87+
</div>
88+
<div class="col-md-3">
89+
<h2>Overview</h2>
90+
<ul>
91+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=518008">Conceptual overview of what is ASP.NET Core</a></li>
92+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699320">Fundamentals of ASP.NET Core such as Startup and middleware.</a></li>
93+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=398602">Working with Data</a></li>
94+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=398603">Security</a></li>
95+
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699321">Client side development</a></li>
96+
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699322">Develop on different platforms</a></li>
97+
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699323">Read more on the documentation site</a></li>
98+
</ul>
99+
</div>
100+
<div class="col-md-3">
101+
<h2>Run & Deploy</h2>
102+
<ul>
103+
<li><a href="https://go.microsoft.com/fwlink/?LinkID=517851">Run your app</a></li>
104+
<li><a href="https://go.microsoft.com/fwlink/?LinkID=517853">Run tools such as EF migrations and more</a></li>
105+
<li><a href="https://go.microsoft.com/fwlink/?LinkID=398609">Publish to Microsoft Azure Web Apps</a></li>
106+
</ul>
107+
</div>
108+
</div>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@{
2+
ViewData["Title"] = "Error";
3+
}
4+
5+
<h1 class="text-danger">Error.</h1>
6+
<h2 class="text-danger">An error occurred while processing your request.</h2>
7+
8+
<h3>Development Mode</h3>
9+
<p>
10+
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
11+
</p>
12+
<p>
13+
<strong>Development environment should not be enabled in deployed applications</strong>, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>, and restarting the application.
14+
</p>

0 commit comments

Comments
 (0)