C
C#Pandetthe

❔ Console input

Hi, is it possible to enable console input in web sdk using Host?
public static async Task Main(string[] args)
{
using IHost host = Host.CreateDefaultBuilder(args)
.ConfigureHostConfiguration(configHost =>
{
configHost.SetBasePath(Directory.GetCurrentDirectory());
configHost.AddJsonFile("Config/hostsettings.json", optional: true);
configHost.AddCommandLine(args);
})
.ConfigureAppConfiguration((hostContext, configApp) =>
{
configApp.AddJsonFile("Config/appsettings.json", optional: true);
configApp.AddJsonFile(
$"Config/appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json",
optional: true);
configApp.AddCommandLine(args);
})
.ConfigureLogging((hostContext, configLogging) =>
{
configLogging.AddConfiguration(hostContext.Configuration.GetSection("Logging"));
configLogging.AddConsole();
configLogging.AddDebug();
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>().ConfigureLogging(logging =>
{
logging.AddConsole();
logging.AddDebug();
}).UseKestrel();
})
public static async Task Main(string[] args)
{
using IHost host = Host.CreateDefaultBuilder(args)
.ConfigureHostConfiguration(configHost =>
{
configHost.SetBasePath(Directory.GetCurrentDirectory());
configHost.AddJsonFile("Config/hostsettings.json", optional: true);
configHost.AddCommandLine(args);
})
.ConfigureAppConfiguration((hostContext, configApp) =>
{
configApp.AddJsonFile("Config/appsettings.json", optional: true);
configApp.AddJsonFile(
$"Config/appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json",
optional: true);
configApp.AddCommandLine(args);
})
.ConfigureLogging((hostContext, configLogging) =>
{
configLogging.AddConfiguration(hostContext.Configuration.GetSection("Logging"));
configLogging.AddConsole();
configLogging.AddDebug();
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>().ConfigureLogging(logging =>
{
logging.AddConsole();
logging.AddDebug();
}).UseKestrel();
})
P
Pandetthe384d ago
.ConfigureServices((hostBuilder, services) =>
{
services.AddDbContext<MainDbContext>(options =>
options.UseSqlServer(hostBuilder.Configuration.GetConnectionString("DefaultConnection")));
services.AddTransient<IStartupFilter, DataContextAutomaticMigrationStartupFilter<MainDbContext>>();
services.AddSingleton<IAuthService, AuthService>();
services.AddHostedService<StartupService>();
services.AddHostedService<MailSenderService>();
services.AddHostedService<SalesSweepService>();
})
.UseConsoleLifetime()
.Build();
await host.RunAsync();
}
.ConfigureServices((hostBuilder, services) =>
{
services.AddDbContext<MainDbContext>(options =>
options.UseSqlServer(hostBuilder.Configuration.GetConnectionString("DefaultConnection")));
services.AddTransient<IStartupFilter, DataContextAutomaticMigrationStartupFilter<MainDbContext>>();
services.AddSingleton<IAuthService, AuthService>();
services.AddHostedService<StartupService>();
services.AddHostedService<MailSenderService>();
services.AddHostedService<SalesSweepService>();
})
.UseConsoleLifetime()
.Build();
await host.RunAsync();
}
J
JakenVeina383d ago
define "enable console input"
P
Pandetthe383d ago
? A oh, I want to add some test commands That can be written in console
J
JakenVeina382d ago
as in you want to be table to type commands into the console, while the application is running? assuming it launches within a console?
A
Accord375d ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ MediaPlayer in WPF occasionally fails```cs public static void PlaySound(string path) { Task.Run(() => ❔ How to Create a C# Code Base for a PC CleanerDoes anyone know of C# to make a base code that for now just clean the %temp% folder just for me to ✅ How to install a callback for an awaited item when using Task.WhenAllHello I am using Task.WhenAll on a List of Tasks. However if a task fails I want to immediately call❔ How to get azure cache for Redis connection string stored in app service as a appsetting variableI have created a azure redis for cache and stored the connection string as application setting varia❔ Giveaway for an online DOTNET ConferenceHello developer students, I am going to give away free tickets to an online dotnet conference whic❔ SoundBoardHi! I am working on a soundboard lately and i got stuck with playing a sound throught microphone. i'❔ accessing object from a class inside of another classI got this class called "Engine"(image 1) that has the object "isOn" which indicates whether the eng❔ QuestionControllerHello, i have a question regarding API structure. I have two classses, Item and Store. I created C❔ Problem Binding to Image SizeI am making an app that displays a series of books. An image and title of the book is to be displaye❔ whats the best site or youtube channel to start learning c#?just downloaded visual studio and wanted to know what would be the best way to learn C#❔ C# MVC - Erroring in VSC not VS2022I'm writing a C# .Net Core 7.0 web application with dapper for my SQL queries. It runs just fine inString Contain issueSo im trying to get a word in a string using Contain but its not getting the word, I havent found a ❔ Catching Exceptions with generic parameters?When adding an entity to the database, i first check if it already exists and if it does I throw an ❔ How should I learn programming?I'm sure this is a common question, but I want to learn game development but am a pretty new C# prog❔ How to properly structure projects in a multi-app MVVM solution?I tend to structure my MVVM projects in the following way: ``` . ├── src/ │ ├── Applications/ │ Sending File and Data to a Minimal API endpointHi. I am using .NET 7, Minimal API and Mailkit. What I want to do is to send an attachment along wi❔ reprotucing the kings pathcan anybody help me fix this code https://paste.mod.gg/sgsvrbaqnmpi/0 ``` the input is number of obs❔ Its there a way to fix this?Hi there, currently I am trying to develop some functions to publish them to azure later, but right ✅ Does this styling code look right?I'm using this code for a simple hover effect. Im wondering if I'm doing this correctly: <Window.Re❔ ?[] operator for dictionariesIs not working. It is explained here. https://learn.microsoft.com/en-us/dotnet/csharp/language-refer