Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. using System;
  2. using Microsoft.AspNetCore;
  3. using Microsoft.AspNetCore.Hosting;
  4.  
  5. namespace TestService
  6. {
  7. public class Service
  8. {
  9. IWebHost _webHost;
  10.  
  11. public Service()
  12. {
  13. _webHost = WebHost.CreateDefaultBuilder()
  14. .UseStartup<Startup>()
  15. .Build();
  16. }
  17.  
  18. public void Start()
  19. {
  20. _webHost.Start();
  21. }
  22. }
  23. }
  24.  
  25. using System;
  26. using Microsoft.AspNetCore.Mvc;
  27. using Microsoft.AspNetCore.Builder;
  28. using Microsoft.AspNetCore.Hosting;
  29. using Microsoft.Extensions.Configuration;
  30. using Microsoft.Extensions.DependencyInjection;
  31.  
  32. namespace TestService
  33. {
  34. public class Startup
  35. {
  36. public Startup(IConfiguration configuration)
  37. {
  38. Configuration = configuration;
  39. }
  40.  
  41. public IConfiguration Configuration { get; }
  42.  
  43. public void ConfigureServices(IServiceCollection services)
  44. {
  45. services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
  46. }
  47.  
  48. public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  49. {
  50. if (env.IsDevelopment()) {
  51. app.UseDeveloperExceptionPage();
  52. }
  53.  
  54. app.UseMvc();
  55. }
  56. }
  57. }
  58.  
  59. <Project Sdk="Microsoft.NET.Sdk">
  60. <PropertyGroup>
  61. <OutputType>Library</OutputType>
  62. <TargetFramework>netcoreapp2.2</TargetFramework>
  63. </PropertyGroup>
  64. <ItemGroup>
  65. <PackageReference Include="Microsoft.AspNetCore" Version="2.2.0"/>
  66. <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0"/>
  67. </ItemGroup>
  68. </Project>
  69.  
  70. using System;
  71.  
  72. namespace TestService.Cli
  73. {
  74. class Program
  75. {
  76. static void Main(string[] args)
  77. {
  78. var service = new Service();
  79. service.Start();
  80. Console.WriteLine("Hello World!");
  81. Console.ReadKey();
  82. }
  83. }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement