'How to use C# 6.0 or 7.0 in an old ASP.NET Website (not Website Project)

I have multiple old ASP.NET webforms websites (this is how to create one from scratch): enter image description here

They are not Website Projects.

ASP.NET Websites seem to be stuck at C# 5. When trying to use features from c# 6 or C# 7 you get an error: enter image description here Trying to use the light bulb upgrade option fails: enter image description here Trying any of the other options found at https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version fail too since there is no .csproj file. or an option in the Project Properties page to change the language version.

Here is what the Build tab looks like on an ASP.NET Website (no Advanced button): enter image description here

I installed the Microsoft.Net.Compilers NuGet package but that made no difference.

Any Ideas if this can be done at all in an ASP.NET website?



Solution 1:[1]

Right click on the project, click on properties, select build tab, click on Advance button at right bottom, select Language Version and click on OK button.

enter image description here

Solution 2:[2]

I run into a project, it is an old asp.net project without .csproj file.

If you create a new asp.net website, you will find the .csproj file, and you can use C# version above 5 happily.

So the problem become: how to generate .csproj file for the old project.

Just create a new project, and copy the code from old project inside Visual Studio. And then copy the new .csproj to the old project. And then your old asp.net project refreshed.:)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ian Boyd
Solution 2 ice6