Skip to content

Commit

Permalink
Enable .csthml views
Browse files Browse the repository at this point in the history
  • Loading branch information
darkthread committed Dec 3, 2023
1 parent ffa1faa commit 97d92a8
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Controllers/CryptoController.cs
Expand Up @@ -13,7 +13,7 @@ public IActionResult Sha1(string data)
SHA1.Create().ComputeHash(
Encoding.UTF8.GetBytes(data.ToString())))
.Replace("-", string.Empty);
return Content($"<pre>{hash}</pre>", "text/html");
return View("Sha1", hash);
}
}
}
2 changes: 1 addition & 1 deletion Program.cs
Expand Up @@ -4,7 +4,7 @@
var builder = WebApplication.CreateBuilder(args);

// 啟用 Controller
builder.Services.AddControllers();
builder.Services.AddMvc();

var app = builder.Build();

Expand Down
2 changes: 2 additions & 0 deletions Views/Crypto/Sha1.cshtml
@@ -0,0 +1,2 @@
@model string
<pre>@Model</pre>
14 changes: 14 additions & 0 deletions Views/Shared/Error.cshtml
@@ -0,0 +1,14 @@
@{
ViewData["Title"] = "Error";
}

<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>Development environment should not be enabled in deployed applications</strong>, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>, and restarting the application.
</p>
13 changes: 13 additions & 0 deletions Views/Shared/_Layout.cshtml
@@ -0,0 +1,13 @@
<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title</title>
</head>
<body>
<div>
@RenderBody()
</div>
</body>
</html>
3 changes: 3 additions & 0 deletions Views/_ViewStart.cshtml
@@ -0,0 +1,3 @@
@{
Layout = "_Layout";
}
5 changes: 5 additions & 0 deletions min-api-add-mvc.csproj
Expand Up @@ -7,4 +7,9 @@
<RootNamespace>min_api_add_mvc</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion wwwroot/index.html
Expand Up @@ -6,7 +6,7 @@
<style>
iframe {
height: 40px;
width: 300px;
width: 320px;
margin-top: 5px;
}
</style>
Expand Down

0 comments on commit 97d92a8

Please sign in to comment.