title: ASP.NET Core 3.1 - Code behind string with accent character issue on IIS server
body: <p>I have a strange issue with a string that contains accented characters in the code behind of a razor page in .NET Core 3.1.</p>
  <p>When I run the code in VS2019 or my local IIS, everything works fine, the string is displayed and injected in SQL using the characters like &quot;é&quot; and &quot;ô&quot; fine. But once we migrate the code on the development IIS, the accent characters are changed to unrecognized characters &quot;�&quot; where accented character should be. I use the same database for the 3 situations.</p>
  <p>The cshtml page are using UTF-8 encoding, but I doubt it matters since the issue is in the code behind as I understand...</p>
  <p>Let's say I have some function OnPost:</p>
  <pre><code>public IActionResult OnPostChangeValue(int objectKey, string newvalue)
  {
       someInterface.someFunction($&quot;Rôle de déploiement: {newvalue}&quot;);
  
       return Page();
  }
  </code></pre>
  <p>The newvalue is coming from the razor page when a button is clicked, a string with some value is posted. The button is part of a table inside a form, built using ajax for datatables.</p>
  <pre><code>&lt;button type=&quot;submit&quot; class=&quot;btn btn-danger&quot; formaction=&quot;./Page?objectKey=' + row.objectKey + '&amp;newvalue=SomeText&amp;handler=ChangeValue&quot;&gt;SomeText&lt;/button&gt;
  </code></pre>
  <p>Then in the interface implementation code I have added a logger to  get the value before the SQL injection to validate if the issue was with SQL or the code itself. NOTE: This class reside in another project/dll that is referenced by the default project.</p>
  <pre><code>public someFunction(string message)
  {
      ILogger.logWarning(message);
  
      using (IDbConnection connection = new SqlConnection(config.GetConnectionString(&quot;someDbString&quot;)))
              {
                  connection.Execute(&quot;dbo.someStoredProcedure @Message&quot;, new {Message = message});
              }
  }
  </code></pre>
  <p>When the code is run on the development server/IIS, the entry are &quot;R�le de d�ploiement: ...&quot;. But if the same code/build is run from Visual Studio or my local IIS (release publish), the entry are &quot;Rôle de déploiement: ...&quot; as expected.</p>
  <p>My question is: how can I fix that and/or is there a setting on IIS/Windows server that could prevent from using accents characters in the code behind?</p>
  <p>Thanks!</p>
  <p>EDIT: Added more information</p>
  <p>EDIT2: I have been able to reproduce the issue on my local IIS.
  We are using Azure DevOps to build and release the webapps on our IIS servers. I have downloaded the Azure Build (which I assumed was the same as I've obtained locally with VS2019) and now I have the issue. So it seems it is caused by something to be found when using the Azure DevOps build...</p>