I have simple enumeration and switch statement like below:
public enum AuthType
{
Auth,
Token
}
public T GetRecord<T>(string queryString, AuthType authType){
switch (authType)
{
case AuthType.Auth:
var response = doSomethingAuth(queryString)
return response
case AuthType.Token:
var response = doSomethingToken(queryString)
return response;
default:
throw new InvalidOperationException("AuthType does not exist");
}
}
var querystring = "&id=12345"
var addressList = _repository.GetRecord<List<Address>>(querystring, AuthType.Token)
When I run my code locally and the authType value is AuthType.Token, then it falls to the correct case.
When I deploy the code to my Azure App Service the switch statement always falls to the first case.
The deployed code is on a very old S1 instance of an Azure App Service plan with runtime set to .Net Framework 4.8.
My local machine is running up to date Windows 10. The application runtime has been updated a couple of times is currently targeted to .Net 4.8.
This is a classic "works on my machine" moment and I am at a loss to explain.
I created web forms in the .NET Framework 4.8 with simple enumeration and switch statements, and they were successfully deployed to Azure App Services.
I used the following code to create this project.
Repository.cs:
Default.aspx.cs:
Default.aspx:
Local Output:
I deployed the web app to Azure using Visual Studio.
Right-click on the project name and select Publish as shown below.
If you have already created a web app in Azure, select the existing one or create a new one.
I successfully published the app to Azure, as shown below.
Azure App Service Output: