Skip to content

Commit

Permalink
add gitignore, change JSON serialization code
Browse files Browse the repository at this point in the history
  • Loading branch information
darkthread committed Feb 19, 2022
1 parent 1fd334c commit 4d61a88
Show file tree
Hide file tree
Showing 40 changed files with 459 additions and 16,997 deletions.
454 changes: 454 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions Controllers/QuestionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Net6WebAPI.Controllers;

[ApiController]
[Route("api/[controller]")]
public class QuestionController : ControllerBase
public class QuestionController : Controller
{
private readonly ILogger<QuestionController> _logger;

Expand All @@ -24,8 +24,7 @@ public ActionResult Why()
Qustion = "想請求大家幫助我解答這個問題,為什麼我已經在program.cs的service加入AddJsonOptions Encoder,編碼還是無法顯示中文?",
Thanks = "謝謝 :)"
};
var js = JsonSerializer.Serialize(result);
return Ok(js);
return this.Json(result);
}


Expand Down
25 changes: 3 additions & 22 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,12 @@

// Add services to the container.

builder.Services.AddControllers().AddJsonOptions(options =>
{
options.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase;
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
options.JsonSerializerOptions.WriteIndented = true;
});
builder.Services.AddMvcCore().AddJsonOptions(options =>
{
options.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase;
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
options.JsonSerializerOptions.WriteIndented = true;
});
builder.Services.AddMvc().AddJsonOptions(options =>
{
options.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase;
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
options.JsonSerializerOptions.WriteIndented = true;
options.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase;
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
options.JsonSerializerOptions.WriteIndented = true;
});
builder.Services.AddRazorPages().AddJsonOptions(options =>
{
options.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase;
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
options.JsonSerializerOptions.WriteIndented = true;
});;


// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
Expand Down
Binary file removed bin/Debug/net6.0/Microsoft.OpenApi.dll
Binary file not shown.
115 changes: 0 additions & 115 deletions bin/Debug/net6.0/Net6WebAPI.deps.json

This file was deleted.

Binary file removed bin/Debug/net6.0/Net6WebAPI.dll
Binary file not shown.
Binary file removed bin/Debug/net6.0/Net6WebAPI.exe
Binary file not shown.
Binary file removed bin/Debug/net6.0/Net6WebAPI.pdb
Binary file not shown.
19 changes: 0 additions & 19 deletions bin/Debug/net6.0/Net6WebAPI.runtimeconfig.json

This file was deleted.

Binary file removed bin/Debug/net6.0/Swashbuckle.AspNetCore.Swagger.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 0 additions & 8 deletions bin/Debug/net6.0/appsettings.Development.json

This file was deleted.

9 changes: 0 additions & 9 deletions bin/Debug/net6.0/appsettings.json

This file was deleted.

Binary file removed bin/Debug/net6.0/ref/Net6WebAPI.dll
Binary file not shown.

This file was deleted.

23 changes: 0 additions & 23 deletions obj/Debug/net6.0/Net6WebAPI.AssemblyInfo.cs

This file was deleted.

1 change: 0 additions & 1 deletion obj/Debug/net6.0/Net6WebAPI.AssemblyInfoInputs.cache

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions obj/Debug/net6.0/Net6WebAPI.GlobalUsings.g.cs

This file was deleted.

Empty file.
16 changes: 0 additions & 16 deletions obj/Debug/net6.0/Net6WebAPI.MvcApplicationPartsAssemblyInfo.cs

This file was deleted.

Binary file removed obj/Debug/net6.0/Net6WebAPI.assets.cache
Binary file not shown.
Binary file not shown.
Empty file.
1 change: 0 additions & 1 deletion obj/Debug/net6.0/Net6WebAPI.csproj.CoreCompileInputs.cache

This file was deleted.

27 changes: 0 additions & 27 deletions obj/Debug/net6.0/Net6WebAPI.csproj.FileListAbsolute.txt

This file was deleted.

Binary file removed obj/Debug/net6.0/Net6WebAPI.dll
Binary file not shown.
1 change: 0 additions & 1 deletion obj/Debug/net6.0/Net6WebAPI.genruntimeconfig.cache

This file was deleted.

Binary file removed obj/Debug/net6.0/Net6WebAPI.pdb
Binary file not shown.
Binary file removed obj/Debug/net6.0/apphost.exe
Binary file not shown.

0 comments on commit 4d61a88

Please sign in to comment.