Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Microsoft.AspNetCore;
- using Microsoft.AspNetCore.Hosting;
- namespace TestService
- {
- public class Service
- {
- IWebHost _webHost;
- public Service()
- {
- _webHost = WebHost.CreateDefaultBuilder()
- .UseStartup<Startup>()
- .Build();
- }
- public void Start()
- {
- _webHost.Start();
- }
- }
- }
- using System;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Builder;
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.DependencyInjection;
- namespace TestService
- {
- public class Startup
- {
- public Startup(IConfiguration configuration)
- {
- Configuration = configuration;
- }
- public IConfiguration Configuration { get; }
- public void ConfigureServices(IServiceCollection services)
- {
- services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
- }
- public void Configure(IApplicationBuilder app, IHostingEnvironment env)
- {
- if (env.IsDevelopment()) {
- app.UseDeveloperExceptionPage();
- }
- app.UseMvc();
- }
- }
- }
- <Project Sdk="Microsoft.NET.Sdk">
- <PropertyGroup>
- <OutputType>Library</OutputType>
- <TargetFramework>netcoreapp2.2</TargetFramework>
- </PropertyGroup>
- <ItemGroup>
- <PackageReference Include="Microsoft.AspNetCore" Version="2.2.0"/>
- <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0"/>
- </ItemGroup>
- </Project>
- using System;
- namespace TestService.Cli
- {
- class Program
- {
- static void Main(string[] args)
- {
- var service = new Service();
- service.Start();
- Console.WriteLine("Hello World!");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement