Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. <Project Sdk="Microsoft.NET.Sdk.Web">
  2.  
  3. <PropertyGroup>
  4. <TargetFramework>netcoreapp2.2</TargetFramework>
  5. </PropertyGroup>
  6.  
  7. <ItemGroup>
  8. <PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
  9. <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
  10. <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.0" />
  11. </ItemGroup>
  12.  
  13. </Project>
  14.  
  15. <configuration>
  16.  
  17. <system.web>
  18. <customErrors mode="Off" />
  19. <authentication mode="None" />
  20. </system.web>
  21.  
  22. <system.webServer>
  23. <modules runAllManagedModulesForAllRequests="true" />
  24. <httpErrors errorMode="Detailed"></httpErrors>
  25. </system.webServer>
  26.  
  27. </configuration>
  28.  
  29. using System;
  30. using System.Collections.Generic;
  31. using System.IO;
  32. using System.Linq;
  33. using System.Threading.Tasks;
  34. using Microsoft.AspNetCore;
  35. using Microsoft.AspNetCore.Hosting;
  36. using Microsoft.Extensions.Configuration;
  37. using Microsoft.Extensions.Logging;
  38.  
  39. namespace API
  40. {
  41. public class Program
  42. {
  43. public static void Main(string[] args)
  44. {
  45. BuildWebHost(args).Run();
  46. }
  47.  
  48. public static IWebHost BuildWebHost(string[] args) =>
  49. WebHost.CreateDefaultBuilder(args)
  50. .UseStartup<Startup>()
  51. .Build();
  52. }
  53. }
  54.  
  55. using System;
  56. using System.Collections.Generic;
  57. using System.Linq;
  58. using System.Threading.Tasks;
  59. using Microsoft.AspNetCore.Builder;
  60. using Microsoft.AspNetCore.Cors.Infrastructure;
  61. using Microsoft.AspNetCore.Hosting;
  62. using Microsoft.AspNetCore.Mvc;
  63. using Microsoft.Extensions.Configuration;
  64. using Microsoft.Extensions.DependencyInjection;
  65. using Microsoft.Extensions.Logging;
  66. using Microsoft.Extensions.Options;
  67.  
  68. namespace API
  69. {
  70. public class Startup
  71. {
  72. public Startup(IHostingEnvironment env)
  73. {
  74. var builder = new ConfigurationBuilder()
  75. .SetBasePath(env.ContentRootPath)
  76. .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
  77. .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
  78. .AddEnvironmentVariables();
  79. Configuration = builder.Build();
  80. }
  81.  
  82. public IConfigurationRoot Configuration { get; }
  83.  
  84. public void ConfigureServices(IServiceCollection services)
  85. {
  86. services.AddMvc();
  87. }
  88.  
  89. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  90. {
  91. app.UseMvc();
  92. }
  93. }
  94. }
  95.  
  96. using System;
  97. using Microsoft.AspNetCore.Mvc;
  98.  
  99. namespace API.Controllers
  100. {
  101. [Route("api/[controller]")]
  102. public class TestController : Controller
  103. {
  104. [HttpGet]
  105. public IActionResult Get()
  106. {
  107. return Content("OK");
  108. }
  109.  
  110. }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement