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.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace HttpCookies
{
public class Startup
{
// 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, IWebHostEnvironment env)
{
app.Run(async (context) =>
{
var cookie = context.Request.Cookies["MyCoolLittleCookie"];
if (string.IsNullOrWhiteSpace(cookie))
{
DateTime now = DateTime.Now;
DateTime expires = now + TimeSpan.FromSeconds(15);
context.Response.Cookies.Append
(
"MyCoolLittleCookie",
"Cookie created at: " + now.ToString("h:mm:ss tt"),
new CookieOptions
{
Path = "/",
HttpOnly = false,
Secure = false,
Expires = expires
}
);
}
string response =
"HTTP Cookies" +
$"
This is the cookie value received from browser: \"[b]{cookie}[/b]\".
" +
"
Refresh page to see current cookie value...
" +
"
Cookie expires after 15 seconds.
";
await context.Response.WriteAsync(response);
});
}
}
}
{
"version": "0.2.0",
"configurations": [
{
// 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
"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/net5.0/HttpCookies.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
и когда я пытаюсь отладить, появляется эта ошибка
"Не удалось найти дескриптор адаптера отладки для типа отладки "coreclr" (возможно, произошел сбой расширения для активации)"
Что мне следует сделать, чтобы устранить эту ошибку? все работало нормально, но внезапно начала появляться эта ошибка,
пожалуйста, помогите
Я пытаюсь отладить это простое веб-приложение. [code]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.DependencyInjection; using Microsoft.Extensions.Hosting;
namespace HttpCookies { public class Startup { // 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, IWebHostEnvironment env) { app.Run(async (context) => { var cookie = context.Request.Cookies["MyCoolLittleCookie"];
if (string.IsNullOrWhiteSpace(cookie)) { DateTime now = DateTime.Now; DateTime expires = now + TimeSpan.FromSeconds(15); context.Response.Cookies.Append ( "MyCoolLittleCookie", "Cookie created at: " + now.ToString("h:mm:ss tt"), new CookieOptions { Path = "/", HttpOnly = false, Secure = false, Expires = expires } ); }
string response = "HTTP Cookies" + $" This is the cookie value received from browser: \"[b]{cookie}[/b]\". " + " Refresh page to see current cookie value... " + " Cookie expires after 15 seconds. "; await context.Response.WriteAsync(response); }); } } } [/code] а это файл launch.json [code]{ "version": "0.2.0", "configurations": [ { // 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 "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/net5.0/HttpCookies.dll", "args": [], "cwd": "${workspaceFolder}", "stopAtEntry": false, // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser "serverReadyAction": { "action": "openExternally", "pattern": "\\bNow listening on:\\s+(https?://\\S+)" }, "env": { "ASPNETCORE_ENVIRONMENT": "Development" }, "sourceFileMap": { "/Views": "${workspaceFolder}/Views" } }, { "name": ".NET Core Attach", "type": "coreclr", "request": "attach" } ] } [/code] и когда я пытаюсь отладить, появляется эта ошибка "Не удалось найти дескриптор адаптера отладки для типа отладки "coreclr" (возможно, произошел сбой расширения для активации)" Что мне следует сделать, чтобы устранить эту ошибку? все работало нормально, но внезапно начала появляться эта ошибка, пожалуйста, помогите
Я пытаюсь отладить это простое веб-приложение.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using...
Недавно я пытался узнать о разработке игр с использованием Unity. Однако когда я открываю сценарий C# с помощью кода VS, он выдает следующую ошибку:
Found installed dotnet location /usr/local/share/dotnet/dotnet to load projects.
.NET SDK was...
Недавно я пытался узнать о разработке игр с использованием Unity. Однако когда я открываю сценарий C# с помощью кода VS, он выдает следующую ошибку:
Found installed dotnet location /usr/local/share/dotnet/dotnet to load projects.
.NET SDK was...
Я пытаюсь встроить консольное приложение A в другое консольное приложение B (проект тестирования NUnit). B ссылается на A с помощью ProjectReference.
При запуске A все работает нормально. Все также в порядке, когда я запускаю B без ссылки на A....