Created
March 18, 2019 22:38
-
-
Save gistlyn/7130a0deee31724d45763e8373efe264 to your computer and use it in GitHub Desktop.
Empty ASP.NET Core 2.1 LTS on .NET Framework ServiceStack App
This file contains hidden or 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
{ | |
"Logging": { | |
"LogLevel": { | |
"Default": "Debug", | |
"System": "Information", | |
"Microsoft": "Information" | |
} | |
} | |
} |
This file contains hidden or 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
{ | |
"Logging": { | |
"LogLevel": { | |
"Default": "Warning" | |
} | |
}, | |
"AllowedHosts": "*" | |
} |
This file contains hidden or 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
<Project Sdk="Microsoft.NET.Sdk.Web"> | |
<PropertyGroup> | |
<TargetFramework>net47</TargetFramework> | |
<TypeScriptToolsVersion>2.8</TypeScriptToolsVersion> | |
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> | |
</PropertyGroup> | |
<ItemGroup> | |
<Folder Include="wwwroot\" /> | |
</ItemGroup> | |
<ItemGroup> | |
<Content Remove="appsettings.Development.json" /> | |
</ItemGroup> | |
<ItemGroup> | |
<PackageReference Include="Microsoft.AspNetCore" Version="2.*" /> | |
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.*" /> | |
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.*" /> | |
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.*" /> | |
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.*" /> | |
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.*" /> | |
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.*" /> | |
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.*" /> | |
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.*" /> | |
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.*" /> | |
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.*" /> | |
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.*" /> | |
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.*" /> | |
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.*" /> | |
<PackageReference Include="ServiceStack.Core" Version="5.*" /> | |
</ItemGroup> | |
</Project> |
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.Logging; | |
namespace MyApp | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
CreateWebHostBuilder(args).Build().Run(); | |
} | |
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => | |
WebHost.CreateDefaultBuilder(args) | |
.UseStartup<Startup>(); | |
} | |
} |
This file contains hidden or 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
{ | |
"profiles": { | |
"IIS Express": { | |
"commandName": "IISExpress", | |
"launchBrowser": true, | |
"environmentVariables": { | |
"ASPNETCORE_ENVIRONMENT": "Development" | |
} | |
}, | |
"MyApp": { | |
"commandName": "Project", | |
"launchBrowser": true, | |
"applicationUrl": "https://localhost:5001;http://localhost:5000", | |
"environmentVariables": { | |
"ASPNETCORE_ENVIRONMENT": "Development" | |
} | |
} | |
} | |
} |
This file contains hidden or 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
using System; | |
using ServiceStack; | |
using MyApp.ServiceModel; | |
namespace MyApp.ServiceInterface | |
{ | |
public class MyServices : Service | |
{ | |
public object Any(Hello request) | |
{ | |
return new HelloResponse { Result = $"Hello, {request.Name}!" }; | |
} | |
} | |
} |
This file contains hidden or 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
using System; | |
using ServiceStack; | |
namespace MyApp.ServiceModel | |
{ | |
[Route("/hello")] | |
[Route("/hello/{Name}")] | |
public class Hello : IReturn<HelloResponse> | |
{ | |
public string Name { get; set; } | |
} | |
public class HelloResponse | |
{ | |
public string Result { get; set; } | |
} | |
} |
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.DependencyInjection; | |
using Funq; | |
using ServiceStack; | |
using MyApp.ServiceInterface; | |
using MyApp.ServiceModel; | |
namespace MyApp | |
{ | |
public class Startup | |
{ | |
public IConfiguration Configuration { get; } | |
public Startup(IConfiguration configuration) => Configuration = configuration; | |
// This method gets called by the runtime. Use this method to add services to the container. | |
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
} | |
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | |
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | |
{ | |
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
} | |
app.UseServiceStack(new AppHost | |
{ | |
AppSettings = new NetCoreAppSettings(Configuration) | |
}); | |
} | |
} | |
public class AppHost : AppHostBase | |
{ | |
public AppHost() : base("My App", typeof(MyServices).Assembly) { } | |
// Configure your AppHost with the necessary configuration and dependencies your App needs | |
public override void Configure(Container container) | |
{ | |
SetConfig(new HostConfig | |
{ | |
DefaultRedirectPath = "/metadata", | |
DebugMode = HostingEnvironment.IsDevelopment() | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment