Wisej3 Startup

0
0

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

  • You must to post comments
0
0

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

  • Luca (ITG)
    It’s in csproj, it’s the <StartupObject>. None if this is created or defined by Wisej. The Main method is static, there is no instantiation of the Startup class. All ASP.NET Core apps are plain executables with a standard Main method which is unrelated to the main method for the Wisej app.
  • You must to post comments
0
0

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

  • Alex Prinias
    Thank you, Luca.. This is what I was missing! A
  • You must to post comments
0
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

  • You must to post comments
0
0

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

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.