This is a migrated thread and some comments may be shown as answers.

asp.net core 3 template using 2.2 syntax

5 Answers 96 Views
Installer and VS Extensions
This is a migrated thread and some comments may be shown as answers.
Bruce
Top achievements
Rank 1
Bruce asked on 25 Sep 2019, 08:47 AM

Why are the 3.0 templates still using older 2.2 code in startup.cs and program.cs? Sure it works but it's not really 3.0 syntax.

Example:

2.2 -> 3.0:

AddMvc -> AddControllersWithViews

IWebHostBuilder -> IHostBuilder

5 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 30 Sep 2019, 07:46 AM

Hello Bruce,

I have performed some local tests, but the described issue was not replicated - the Core 3.0 referenced are correctly applied in the respective Project Template. Could you please share a bit more about the steps for replication. What is the exact type of project that you've created and with which Visual Studio (2019 or 2019 Preview). Also, which version is your Visual Studio and what is the SDK that you have installed at your end?

Regards,
Nencho
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Bruce
Top achievements
Rank 1
answered on 30 Sep 2019, 08:02 AM

Hi Nencho,

Visual Studio 16.3.1 | Telerik ASP.NET Core 2019.3.917

See attached images of how the code looks after creating a project from a Telerik template. How do I get a new template that uses the preferred syntax for ASP.NET Core 3 MVC projects i.e. AddControllersWithViews and IHostbuilder instead of the 2.2 sytax of AddMvc and IWebHostBuilder?

 

0
Nencho
Telerik team
answered on 30 Sep 2019, 01:37 PM

Hello Bruce,

Thank you very much for the screenshots and feedback provided. Indeed the official Core 3.0 was released couple of days after our official release, which is why we target such enhancements for the upcoming Service pack, scheduled for the end of the month (October). The IHostBuilder will definitely be included in the template, however, it seems like the AddControllersWithViews is not suitable for Pages scenario (source). Could you please share your point of view and the necessity to have it in a new project?

Regards,
Nencho
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Bruce
Top achievements
Rank 1
answered on 30 Sep 2019, 03:13 PM

Thanks for the reply Nencho.

I believe the 3.0 documentation states that for Pages Scenario you just use:

public void ConfigureServices(IServiceCollection services)
{
    services.AddRazorPages();
}

https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio

As stated in the first post - the older way works but it seems strange that the newer templates are not adopting the new syntax,  which might be deprecated before its time.

0
Accepted
Nencho
Telerik team
answered on 01 Oct 2019, 02:22 PM

Hello Bruce,

I have revised again the implementation of the templates, and indeed, we can have the AddRazorPages usage only on the RazorPages template, while the AddControllersWithViews will be applied to all other Templates. The changes will be released with the upcoming Service Pack.

Thank you for your valuable feedback. I have updated your Telerik Points on the matter.

Regards,
Nencho
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Installer and VS Extensions
Asked by
Bruce
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Bruce
Top achievements
Rank 1
Share this question
or