I'm trying to use a local function in my asp.net web-site:
public class Handler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
Int32 Seven()
{
return 7;
}
}
}
But i get an compile-time error:
CS8026 Feature 'local functions' is not available in C# 5. Please use language version 7.0 or greater.
Ok then.
How to use Language Version 7.0 or greater in an ASP.net web-site?
It seems everyone knows how to upgrade an ASP.net web-application to a newer version of C#. But how to you upgrade an ASP.net web-site to a newer version of C#?
One person suggests going into the properties of your project; forgetting that web-sites don't have projects (again, that's web applications).
Someone else suggests adding magic cargo-cult programming to your web.config
:
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
except that just causes more compile-time errors:
The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located.
Someone else suggests you install something (Microsoft.CodeDom.Providers.DotNetCompilerPlatform
); except he doesn't explain what that is, or how to install it.
Stop fumbling around
So that's enough Googling, randomly trying half-answers that cause more problems. It's time to get the answer.
What is the correct, complete, actual, designed, supported, intended way to use C# 8 in an ASP.net web-site?
Bonus: