Hi guys,
First of all, CONGRATULATIONS on the release of Wisej3 ! ! !
I just created a new Wisej3 Web Application project and I would like to ask you about the usage of Startup.cs, because I’m puzzled.
In other ASP.Net Core projects (e.g. Web API) it is “invoked” by the Program.cs, while building the host, with a .UseStartup<Startup>() extension, something like
var webHost = WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
config
.AddJsonFile(“appsettings.json”, optional: false, reloadOnChange: true)
.AddJsonFile($”appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json”, optional: true, reloadOnChange: true)
.AddEnvironmentVariables();
})
.UseStartup<Startup>()
.Build();
Then the built webHost is run in the Program.Main.
I do not see any reference to Startup in your case. How is it invoked?
Happy Easter and all the best!
Alex
Hi Luca,
well, it seems I still miss something…
As you said the UseStartup is deprecated in .net 6. However, the default Wisej3 project template creates a Startup.cs, which includes the app.UseWisej();
According to Microsoft docs, https://docs.microsoft.com/en-us/aspnet/core/migration/50-to-60?view=aspnetcore-6.0&tabs=visual-studio#smhm
if one wants to use a Startup, one has to instantiate the Startup class like
var builder = WebApplication.CreateBuilder(args);
var startup = new Startup(builder.Configuration);
startup.ConfigureServices(builder.Services);
var app = builder.Build();
startup.Configure(app, app.Environment);
app.Run();
Such a reference to Startup is not included in the Wisej3 project’s Program.Main, which is defined as the entry point in default.json.
Moreover, the build action for the Startup.cs is set to Content, NOT to Compile (I found this the hard way, when I excluded the Startup.cs fro the project, then re-inluded it and the action was set to compile but there were build errors everywhere after that).
So, how is app.UseWisej() called? It is certainly not hit if I set a break point.
Best,
Alex
UseStartup has been deprecated in NET 6. Wisej doesn’t really care since it’s a middleware just like any other. All it needs is UseWisej.
https://docs.microsoft.com/en-us/aspnet/core/migration/50-to-60-samples?view=aspnetcore-6.0
Hi Thomas, thanks for your answer.
I’ve seen the instructions. But what I’m saying is that I do not see any place with a .UseStartup<Startup> to connect the Startup class with the host.
What am I missing?
Best,
Alex
Hi Alex, it is similar in Wisej 3. See the following link to get it working:
https://docs.wisej.com/docs/releases/whats-new-in-3.0/update-existing-projects
Best wishes
Thomas
Please login first to submit.