From ce81b993fd271be9552799eabb324d5c7ca1c5bb Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sun, 10 Feb 2019 23:03:55 +0000 Subject: Made project for ASP.NET server --- Server/.vscode/launch.json | 46 ++++++++++++++++++++++++++++++++++++++++++++++ Server/.vscode/tasks.json | 15 +++++++++++++++ Server/Program.cs | 24 ++++++++++++++++++++++++ Server/Server.csproj | 12 ++++++++++++ Server/Startup.cs | 41 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 138 insertions(+) create mode 100644 Server/.vscode/launch.json create mode 100644 Server/.vscode/tasks.json create mode 100644 Server/Program.cs create mode 100644 Server/Server.csproj create mode 100644 Server/Startup.cs diff --git a/Server/.vscode/launch.json b/Server/.vscode/launch.json new file mode 100644 index 0000000..7a4e712 --- /dev/null +++ b/Server/.vscode/launch.json @@ -0,0 +1,46 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.1/Server.dll", + "args": [], + "cwd": "${workspaceFolder}", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart", + "launchBrowser": { + "enabled": true, + "args": "${auto-detect-url}", + "windows": { + "command": "cmd.exe", + "args": "/C start ${auto-detect-url}" + }, + "osx": { + "command": "open" + }, + "linux": { + "command": "xdg-open" + } + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ,] +} \ No newline at end of file diff --git a/Server/.vscode/tasks.json b/Server/.vscode/tasks.json new file mode 100644 index 0000000..93c8951 --- /dev/null +++ b/Server/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/Server.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Server/Program.cs b/Server/Program.cs new file mode 100644 index 0000000..4144500 --- /dev/null +++ b/Server/Program.cs @@ -0,0 +1,24 @@ +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 Server +{ + public class Program + { + public static void Main(string[] args) + { + CreateWebHostBuilder(args).Build().Run(); + } + + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup(); + } +} diff --git a/Server/Server.csproj b/Server/Server.csproj new file mode 100644 index 0000000..ed02613 --- /dev/null +++ b/Server/Server.csproj @@ -0,0 +1,12 @@ + + + + netcoreapp2.1 + + + + + + + + diff --git a/Server/Startup.cs b/Server/Startup.cs new file mode 100644 index 0000000..08d1df4 --- /dev/null +++ b/Server/Startup.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; + +namespace Server { + public class Startup { + public Startup(IConfiguration configuration) { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) { + services.Configure(options => { + // This lambda determines whether user consent for non-essential cookies is needed for a given request. + options.CheckConsentNeeded = context => true; + options.MinimumSameSitePolicy = SameSiteMode.None; + }); + } + + // 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(); + } + else { + app.UseExceptionHandler("/Error"); + app.UseHsts(); + } + + app.UseHttpsRedirection(); + app.UseStaticFiles(); + app.UseCookiePolicy(); + } + } +} -- cgit v1.2.3-13-gbd6f