A modern web application built with ASP.NET Core 9.0 and Blazor Server components.

๐Ÿš€ Quick Start

Prerequisites

Before you begin, ensure you have the following installed on your Mac:

  • .NET 9.0 SDK - Download here
  • Git - Usually pre-installed on macOS, or install via Homebrew
  • Visual Studio Code (recommended) or Visual Studio for Mac

Installation

  1. Clone the repository

    git clone <your-repository-url>
    cd aspnet
    
  2. Verify .NET installation

    dotnet --version
    # Should show 9.0.x or higher
    
  3. Restore dependencies

    dotnet restore
    
  4. Build the project

    dotnet build
    
  5. Run the application

    dotnet run --project aspnet
    
  6. Open in browser

    • Navigate to https://localhost:5001 or http://localhost:5000
    • The application will automatically open in your default browser

๐Ÿ› ๏ธ Development Setup

Install these extensions for the best development experience:


code --install-extension ms-dotnettools.csharp
code --install-extension ms-dotnettools.blazorwasm-companion
code --install-extension ms-vscode.vscode-json
code --install-extension bradlc.vscode-tailwindcss  # If using Tailwind CSS

Or search for these in VS Code Extensions marketplace:

  • C# Dev Kit - IntelliSense, debugging, and project management
  • Blazor WASM Companion - Enhanced Blazor development
  • JSON - JSON file support
  • Auto Rename Tag - Automatically rename paired HTML/XML tags

Project Structure

aspnet/
โ”œโ”€โ”€ Components/           # Blazor components
โ”‚   โ”œโ”€โ”€ Layout/          # Layout components (MainLayout, NavMenu)
โ”‚   โ”œโ”€โ”€ Pages/           # Page components (Home, Counter, Weather)
โ”‚   โ”œโ”€โ”€ App.razor        # Root component
โ”‚   โ”œโ”€โ”€ Routes.razor     # Routing configuration
โ”‚   โ””โ”€โ”€ _Imports.razor   # Global using statements
โ”œโ”€โ”€ Properties/          # Launch settings
โ”œโ”€โ”€ wwwroot/            # Static files (CSS, JS, images)
โ”œโ”€โ”€ appsettings.json    # Application configuration
โ”œโ”€โ”€ Program.cs          # Application entry point
โ””โ”€โ”€ aspnet.csproj       # Project file

๐Ÿ”ง Development Commands

Building and Running


dotnet clean

dotnet restore

dotnet build

dotnet run --project aspnet

dotnet watch --project aspnet

dotnet build --configuration Release

dotnet publish --configuration Release --output ./publish

Testing


dotnet test

dotnet test --collect:"XPlat Code Coverage"

dotnet test path/to/test/project

๐ŸŒ Environment Configuration

Development Settings

The application uses different configuration files for different environments:

  • appsettings.json - Base configuration
  • appsettings.Development.json - Development overrides
  • appsettings.Production.json - Production overrides (create if needed)

Environment Variables

Set environment variables for local development:


export ASPNETCORE_ENVIRONMENT=Development

export ASPNETCORE_URLS="https://localhost:5001;http://localhost:5000"

echo 'export ASPNETCORE_ENVIRONMENT=Development' >> ~/.zshrc

๐Ÿ› Debugging

VS Code Debugging

  1. Open the project in VS Code
  2. Go to Run and Debug (โ‡งโŒ˜D)
  3. Select โ€œ.NET Core Launch (web)โ€ configuration
  4. Set breakpoints in your code
  5. Press F5 to start debugging

Browser Developer Tools

  • Chrome DevTools: F12 or Cmd+Option+I
  • Blazor debugging: Enable in browser dev tools under Sources tab

๐Ÿ“ฆ Package Management

Adding NuGet Packages


dotnet add aspnet package PackageName

dotnet add aspnet package PackageName --version 1.2.3

dotnet add aspnet package PackageName --package-directory packages

Updating Packages


dotnet list aspnet package --outdated

dotnet add aspnet package PackageName

dotnet add aspnet package PackageName --version "*"

๐Ÿš€ Deployment

Local Production Build


dotnet publish aspnet --configuration Release --output ./dist

cd dist
dotnet aspnet.dll

Docker (Optional)

Create a Dockerfile in the root directory:

FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
COPY ["aspnet/aspnet.csproj", "aspnet/"]
RUN dotnet restore "aspnet/aspnet.csproj"
COPY . .
WORKDIR "/src/aspnet"
RUN dotnet build "aspnet.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "aspnet.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "aspnet.dll"]

Build and run with Docker:


docker build -t aspnet-app .

docker run -p 8080:80 aspnet-app

๐Ÿ” Troubleshooting

Common Issues

  1. Port already in use

    # Find process using port 5000/5001
    lsof -ti:5000
    lsof -ti:5001
    
    # Kill process
    kill -9 <PID>
    
  2. Certificate issues (HTTPS)

    # Trust development certificate
    dotnet dev-certs https --trust
    
  3. Clear NuGet cache

    dotnet nuget locals all --clear
    
  4. Reset to clean state

    dotnet clean
    rm -rf bin obj
    dotnet restore
    dotnet build
    

Performance Tips

  • Use dotnet watch for development to enable hot reload
  • Enable browser caching for static assets in production
  • Use --configuration Release for production builds
  • Monitor memory usage with dotnet-counters

๐Ÿ“š Additional Resources

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

Let's work together ๐Ÿค

Line
Christopher Kelker

Chriscreates