A .NET 8 web application for shortening URLs with QR code generation capabilities, built with ASP.NET Core and Azure Table Storage.
- .NET 8 SDK
- Azure Storage Account (for storing URL mappings)
- Optional: Visual Studio 2022 or VS Code with C# extensions
The application requires configuration in appsettings.json or via user secrets:
- Azure Storage Connection String: Configure the Azure Table Storage connection
- Security Token: Set a security token for protected operations
- QR Code Theme (optional): Customize QR code appearance
cd Egineering.UrlShortener
dotnet user-secrets set "ConnectionStrings:AzureStorage" "your-azure-storage-connection-string"
dotnet user-secrets set "SecurityToken" "your-security-token"Create or update Egineering.UrlShortener/appsettings.Development.json:
{
"ConnectionStrings": {
"AzureStorage": "UseDevelopmentStorage=true"
},
"SecurityToken": "your-dev-token"
}Note: For local development, you can use Azurite emulator with UseDevelopmentStorage=true.
Due to Windows port restrictions (Hyper-V reserved ports), use explicit port configuration:
dotnet run --project Egineering.UrlShortener/Egineering.UrlShortener.csproj --urls "http://localhost:8080;https://localhost:8081"The application will start at:
- HTTP:
http://localhost:8080 - HTTPS:
https://localhost:8081
- Open
Egineering.UrlShortener.sln - Set
Egineering.UrlShorteneras the startup project - Press F5 or click the Run button
- Open the workspace folder
- Press F5 or use the Run and Debug panel
- Select ".NET Core Launch (web)" configuration
- Main Page:
http://localhost:8080/- View all shortened URLs - Setup Page:
http://localhost:8080/setup- Configure security key - Swagger UI:
http://localhost:8080/swagger(Development mode only)
To generate a QR code, base64 encode a URL and make a GET request to /api/qr/{url} or a POST request to /api/qr with the base64 encoded URL in the payload. For example:
curl https://yoururl.com/api/qr -k -X POST -d '{"url":"d3d3LmUtZ2luZWVyaW5nLmNvbS9jb250YWN0LXVz"}' -H 'content-type: application/json'- Egineering.UrlShortener - Main web application (ASP.NET Core)
- Egineering.UrlShortener.Services - Business logic and Azure Table Storage service
- wwwroot - Static files (HTML, CSS, JavaScript)
- .NET 8 - Runtime and framework
- ASP.NET Core - Web framework
- Azure Table Storage - URL mapping storage
- Material Components for the Web - UI components
- QRCoder - QR code generation (assumed from QR functionality)
If you encounter "An attempt was made to access a socket in a way forbidden by its access permissions":
Windows users: This is caused by Hyper-V reserving port ranges. Use the explicit port configuration:
dotnet run --project Egineering.UrlShortener/Egineering.UrlShortener.csproj --urls "http://localhost:8080;https://localhost:8081"To check which ports are reserved on your system:
netsh interface ipv4 show excludedportrange protocol=tcpIf you see connection errors, verify:
- Your connection string is correctly configured
- Azure Storage account is accessible
- For local development, Azurite emulator is running
Run dotnet restore to ensure all NuGet packages are installed.