Skip to content

Commit 9bb14ff

Browse files
committed
Add initial project structure and basic Razor Pages setup
1 parent 6159931 commit 9bb14ff

80 files changed

Lines changed: 83055 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/cicd.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: CI/CD for Azure Web App
2+
3+
on: [push]
4+
5+
permissions:
6+
id-token: write
7+
contents: read
8+
9+
env:
10+
AZURE_WEBAPP_NAME: app-gh-aspnet-webapp-01 # set this to your application's name
11+
AZURE_WEBAPP_PACKAGE_PATH: './src' # set this to the path to your web app project, defaults to the repository root
12+
DOTNET_VERSION: '9.0.x' # set this to the dot net version to use
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
# Checkout the repo
20+
- uses: actions/checkout@main
21+
22+
# Setup .NET Core SDK
23+
- name: Setup .NET Core
24+
uses: actions/setup-dotnet@v3
25+
with:
26+
dotnet-version: ${{ env.DOTNET_VERSION }}
27+
28+
# Run dotnet build and publish
29+
- name: dotnet build and publish
30+
run: |
31+
dotnet restore
32+
dotnet build --configuration Release
33+
dotnet publish -c Release --property:PublishDir='${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/publish'
34+
35+
- name: Azure Login
36+
uses: azure/login@v2
37+
with:
38+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
39+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
40+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
41+
42+
# Deploy to Azure Web apps
43+
- name: 'Run Azure webapp deploy action using publish profile credentials'
44+
uses: azure/webapps-deploy@v3
45+
with:
46+
app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app name
47+
package: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/publish'
48+
49+
- name: logout
50+
run: |
51+
az logout

src/webapp01/Pages/Error.cshtml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@page
2+
@model ErrorModel
3+
@{
4+
ViewData["Title"] = "Error";
5+
}
6+
7+
<h1 class="text-danger">Error.</h1>
8+
<h2 class="text-danger">An error occurred while processing your request.</h2>
9+
10+
@if (Model.ShowRequestId)
11+
{
12+
<p>
13+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
14+
</p>
15+
}
16+
17+
<h3>Development Mode</h3>
18+
<p>
19+
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
20+
</p>
21+
<p>
22+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
23+
It can result in displaying sensitive information from exceptions to end users.
24+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
25+
and restarting the app.
26+
</p>

src/webapp01/Pages/Error.cshtml.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Diagnostics;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.AspNetCore.Mvc.RazorPages;
4+
5+
namespace webapp01.Pages;
6+
7+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
8+
[IgnoreAntiforgeryToken]
9+
public class ErrorModel : PageModel
10+
{
11+
public string? RequestId { get; set; }
12+
13+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
14+
15+
private readonly ILogger<ErrorModel> _logger;
16+
17+
public ErrorModel(ILogger<ErrorModel> logger)
18+
{
19+
_logger = logger;
20+
}
21+
22+
public void OnGet()
23+
{
24+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
25+
}
26+
}
27+

src/webapp01/Pages/Index.cshtml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@page
2+
@model IndexModel
3+
@{
4+
ViewData["Title"] = "Home page";
5+
}
6+
7+
<div class="card text-center">
8+
<div class="card-body">
9+
<h5 class="card-title">.NET 💜 Azure</h5>
10+
<p class="card-text">Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
11+
</div>
12+
</div>

src/webapp01/Pages/Index.cshtml.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
4+
namespace webapp01.Pages;
5+
6+
public class IndexModel : PageModel
7+
{
8+
private readonly ILogger<IndexModel> _logger;
9+
10+
public IndexModel(ILogger<IndexModel> logger)
11+
{
12+
_logger = logger;
13+
}
14+
15+
public void OnGet()
16+
{
17+
18+
}
19+
}

src/webapp01/Pages/Privacy.cshtml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@page
2+
@model PrivacyModel
3+
@{
4+
ViewData["Title"] = "Privacy Policy";
5+
}
6+
<h1>@ViewData["Title"]</h1>
7+
8+
<p>Use this page to detail your site's privacy policy.</p>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
4+
namespace webapp01.Pages;
5+
6+
public class PrivacyModel : PageModel
7+
{
8+
private readonly ILogger<PrivacyModel> _logger;
9+
10+
public PrivacyModel(ILogger<PrivacyModel> logger)
11+
{
12+
_logger = logger;
13+
}
14+
15+
public void OnGet()
16+
{
17+
}
18+
}
19+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>@ViewData["Title"] - webapp01</title>
7+
<script type="importmap"></script>
8+
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
9+
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
10+
<link rel="stylesheet" href="~/webapp01.styles.css" asp-append-version="true" />
11+
</head>
12+
<body>
13+
<header>
14+
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
15+
<div class="container">
16+
<a class="navbar-brand" asp-area="" asp-page="/Index">webapp01</a>
17+
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
18+
aria-expanded="false" aria-label="Toggle navigation">
19+
<span class="navbar-toggler-icon"></span>
20+
</button>
21+
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
22+
<ul class="navbar-nav flex-grow-1">
23+
<li class="nav-item">
24+
<a class="nav-link text-dark" asp-area="" asp-page="/Index">Home</a>
25+
</li>
26+
<li class="nav-item">
27+
<a class="nav-link text-dark" asp-area="" asp-page="/Privacy">Privacy</a>
28+
</li>
29+
</ul>
30+
</div>
31+
</div>
32+
</nav>
33+
</header>
34+
<div class="container">
35+
<main role="main" class="pb-3">
36+
@RenderBody()
37+
</main>
38+
</div>
39+
40+
<footer class="border-top footer text-muted">
41+
<div class="container">
42+
&copy; 2025 - webapp01 - <a asp-area="" asp-page="/Privacy">Privacy</a>
43+
</div>
44+
</footer>
45+
46+
<script src="~/lib/jquery/dist/jquery.min.js"></script>
47+
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
48+
<script src="~/js/site.js" asp-append-version="true"></script>
49+
50+
@await RenderSectionAsync("Scripts", required: false)
51+
</body>
52+
</html>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
2+
for details on configuring this project to bundle and minify static web assets. */
3+
4+
a.navbar-brand {
5+
white-space: normal;
6+
text-align: center;
7+
word-break: break-all;
8+
}
9+
10+
a {
11+
color: #0077cc;
12+
}
13+
14+
.btn-primary {
15+
color: #fff;
16+
background-color: #1b6ec2;
17+
border-color: #1861ac;
18+
}
19+
20+
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
21+
color: #fff;
22+
background-color: #1b6ec2;
23+
border-color: #1861ac;
24+
}
25+
26+
.border-top {
27+
border-top: 1px solid #e5e5e5;
28+
}
29+
.border-bottom {
30+
border-bottom: 1px solid #e5e5e5;
31+
}
32+
33+
.box-shadow {
34+
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
35+
}
36+
37+
button.accept-policy {
38+
font-size: 1rem;
39+
line-height: inherit;
40+
}
41+
42+
.footer {
43+
position: absolute;
44+
bottom: 0;
45+
width: 100%;
46+
white-space: nowrap;
47+
line-height: 60px;
48+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
2+
<script src="~/lib/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.min.js"></script>

0 commit comments

Comments
 (0)