Skip to content

Commit

Permalink
update controllers to aspnetcore3
Browse files Browse the repository at this point in the history
  • Loading branch information
OdeToCode committed Nov 10, 2019
1 parent e98b028 commit a2444b5
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 59 deletions.
27 changes: 27 additions & 0 deletions All/src/Configuration/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:54712/",
"sslPort": 44394
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Configuration": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}
14 changes: 2 additions & 12 deletions All/src/Controllers/Controllers.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>Controllers</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Controllers</PackageId>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<None Update="wwwroot\**\*">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

</Project>
19 changes: 3 additions & 16 deletions All/src/Controllers/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.IO;
using System.Reflection;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;

namespace Controllers
Expand All @@ -9,19 +7,8 @@ public class Program
{
public static void Main(string[] args)
{
var assemblies = Assembly.GetEntryAssembly().GetReferencedAssemblies();
foreach (var assembly in assemblies)
{
Console.WriteLine($"{assembly.Version} {assembly.Name}");

var codebase = Assembly.Load(assembly).CodeBase.Replace("file:///", "");
Console.WriteLine($"\t{Path.GetDirectoryName(codebase)}");
}

var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
var host = WebHost
.CreateDefaultBuilder()
.UseStartup<Startup>()
.Build();

Expand Down
13 changes: 7 additions & 6 deletions All/src/Controllers/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApplicationModels;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Controllers
{


public class Startup
{
Expand All @@ -20,8 +18,8 @@ public void ConfigureServices(IServiceCollection services)
services.Configure<MvcOptions>(o =>
{
o.ModelMetadataDetailsProviders.Add(new MyBindingMetadataProvider());
// o.ModelBinderProviders.Insert(0, new EmbeddedJsonModelBinderProvider());
o.InputFormatters.Add(new XmlSerializerInputFormatter());
o.ModelBinderProviders.Insert(0, new EmbeddedJsonModelBinderProvider());
o.InputFormatters.Add(new XmlSerializerInputFormatter(o));
o.OutputFormatters.Add(new XmlSerializerOutputFormatter());
});
}
Expand All @@ -30,7 +28,10 @@ public void Configure(IApplicationBuilder app)
{
app.UseDeveloperExceptionPage();
app.UseStaticFiles();
app.UseMvc();
app.UseEndpoints(e =>
{
e.MapControllers();
});

app.Run(async (context) =>
{
Expand Down
2 changes: 1 addition & 1 deletion All/src/Controllers/Views/Request/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@model Microsoft.AspNet.Http.Headers.RequestHeaders
@model Microsoft.AspNetCore.Http.Headers.RequestHeaders

<table>
@foreach (var header in Model.Headers)
Expand Down
24 changes: 0 additions & 24 deletions All/src/Controllers/web.config

This file was deleted.

0 comments on commit a2444b5

Please sign in to comment.