A WCF-based file management solution for ASP.NET Web applications with antivirus integration and client-side polling notification system.
UnifiedFileGateway is a prototype solution designed to address file management challenges across multiple ASP.NET Web application instances (Central Portal) that share the same codebase but differ in configuration. The solution provides a unified interface for file operations with integrated antivirus scanning and user notification capabilities.
The system manages files across one ASP.NET Web application instance:
- Central Portal - Centralized file management
Key challenges addressed:
- File Processing: Special folders like
CentralStorage(processed by external antivirus) - User Notification: Notifying users when files uploaded to
CentralStoragehave been processed by external antivirus - Cross-Platform Communication: Enabling communication between different application instances
- Large File Handling: Supporting efficient upload/download of large files
The solution implements client-side polling for antivirus completion notification:
- Clients periodically check file status using
GetFileStatus()method - Files start with
Scanningstatus during antivirus processing - Status changes to
CleanorInfectedwhen processing completes - Clients can download files only when status is
Clean
- .NET 8.0 - .NET framework
- CoreWCF - WCF implementation for .NET Core/8.0
- System.ServiceModel - Standard WCF client library
- SOAP Protocol - For external client compatibility
- MTOM (Message Transmission Optimization Mechanism) - For efficient large file streaming
- Kestrel - Web server for hosting the WCF service
- React - Frontend framework for the Web UI
- Tailwind CSS - Utility-first CSS framework for styling
UnifiedFileGateway/
├── UnifiedFileGateway.sln # Main solution file
├── UnifiedFileGateway.Contracts/ # Shared WCF contracts
│ ├── IFileService.cs # Service interface
│ ├── FileUploadMessage.cs # Upload message contract
│ └── FileStatus.cs # File status enumeration
├── UnifiedFileGateway.Service/ # Service implementation
│ ├── FileService.cs # WCF service implementation
│ └── MicrosoftDefenderScanner.cs # Microsoft Defender integration
├── UnifiedFileGateway.Host/ # Service host application
│ └── Program.cs # Host configuration
└── UnifiedFileGateway.Client/ # Client application
│ ├── Program.cs # Client demonstration
│ └── TestVirusFile.cs # EICAR test virus file helper
└── UnifiedFileGateway.WebUI/ # Web UI client
├── src/ # React source code
├── public/ # Static files
├── package.json # Node.js dependencies
└── README.md # Web UI documentation
- Upload: Upload files with automatic Microsoft Defender antivirus scanning
- Download: Download files (only when clean)
- Delete: Remove files from storage
- Status Check: Poll file processing status
- Microsoft Defender Integration: Real-time antivirus scanning using local Microsoft Defender
- PowerShell Integration: Uses PowerShell cmdlets for Microsoft Defender operations
- Fallback Protection: Graceful handling when Microsoft Defender is unavailable
- Threat Detection: Automatic detection and handling of infected files
- EICAR Test Support: Built-in support for testing with EICAR standard test virus files
NotFound- File doesn't existScanning- File is being processed by Microsoft DefenderClean- File passed antivirus scanInfected- File failed antivirus scan (threat detected)
- MTOM encoding for efficient streaming
- Configurable message size limits
- Memory-efficient file handling
- Modern React Interface: Beautiful and intuitive web interface with Tailwind CSS
- Drag & Drop Upload: Convenient file upload with drag and drop functionality
- Real-time Status: Live updates of file scanning status
- Responsive Design: Works on all devices and screen sizes
- Folder Management: Support for different folders (CentralStorage, TP-Skizzen, Temp)
- Notification System: User-friendly notifications for all operations
- .NET 8.0 SDK
- Visual Studio 2022 or VS Code (optional)
- Node.js 16+ (for Web UI)
- npm or yarn (for Web UI)
-
Clone or navigate to the project directory
cd UnifiedFileGateway -
Restore dependencies
dotnet restore
-
Build the solution
dotnet build
-
Start the WCF service host
dotnet run --project UnifiedFileGateway.Host
The service will start on
http://localhost:8088with the following endpoints:- Service Endpoint:
http://localhost:8088/FileService - Binding: BasicHttpBinding with MTOM encoding
- Security: None (for prototype purposes)
- Service Endpoint:
-
Verify the service is running
- Look for:
Now listening on: http://[::]:8088 - The service is ready when you see:
Application started. Press Ctrl+C to shut down.
- Look for:
-
In a new terminal, run the client
dotnet run --project UnifiedFileGateway.Client
-
Observe the workflow
- Microsoft Defender status check on startup
- Clean file upload and scanning
- EICAR test virus file upload and detection
- Status polling (every 2 seconds)
- File download (only when clean)
- Content verification
- File cleanup
-
Navigate to the Web UI directory
cd sources/UnifiedFileGateway.WebUI -
Install dependencies
npm install
-
Start the development server
npm start
-
Open your browser
http://localhost:3000
Note: Make sure the WCF service is running before using the Web UI.
// Create WCF client
var binding = new BasicHttpBinding(BasicHttpSecurityMode.None)
{
MaxReceivedMessageSize = int.MaxValue,
MessageEncoding = WSMessageEncoding.Mtom
};
var endpoint = new EndpointAddress("http://localhost:8088/FileService");
var factory = new ChannelFactory<IFileService>(binding, endpoint);
var client = factory.CreateChannel();
// Upload file
using (var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
using (var uploadMessage = new FileUploadMessage { FileName = fileName, FileData = fileStream })
{
await client.UploadFile(uploadMessage);
}
// Poll for status
FileStatus status;
do
{
await Task.Delay(2000);
status = await client.GetFileStatus(fileName);
} while (status == FileStatus.Scanning);
// Download file (if clean)
if (status == FileStatus.Clean)
{
var stream = await client.DownloadFile(fileName);
// Process downloaded file
}
// Delete file
await client.DeleteFile(fileName);For integration with your ASP.NET applications:
- Add project reference to
UnifiedFileGateway.Contracts - Create WCF client using the same binding configuration
- Implement polling logic in your web application
- Handle file operations based on status responses
The service can be configured by modifying UnifiedFileGateway.Host/Program.cs:
// Change port
options.ListenAnyIP(8088);
// Modify binding settings
var binding = new BasicHttpBinding(BasicHttpSecurityMode.None)
{
MaxReceivedMessageSize = int.MaxValue,
MaxBufferSize = int.MaxValue,
MessageEncoding = WSMessageEncoding.Mtom
};File storage location is configured in UnifiedFileGateway.Service/FileService.cs:
// Default: System temp directory
_storagePath = Path.Combine(Path.GetTempPath(), "UnifiedFileGatewayStorage");
// Custom path example:
_storagePath = @"C:\FileStorage\UnifiedFileGateway";BasicHttpSecurityMode.None for simplicity. In production:
- Enable HTTPS with proper certificates
- Implement authentication (Windows Authentication, Basic Auth, or custom)
- Configure authorization for file operations
- Use secure file storage with proper access controls
- Implement audit logging for file operations
-
Port already in use
# Find process using port 8088 netstat -ano | findstr :8088 # Kill the process (replace PID with actual process ID) taskkill /PID <PID> /F
-
Build errors
- Ensure .NET 8.0 SDK is installed
- Run
dotnet restorebefore building - Check all project references are correct
-
Client connection issues
- Verify service is running on correct port
- Check firewall settings
- Ensure binding configuration matches between client and server
The service provides detailed logging:
- Host startup: Service binding and endpoint information
- Request processing: File operations and status changes
- Error handling: Exception details and stack traces
- UnifiedFileGateway.Contracts: .NET Standard 2.0 (for compatibility)
- UnifiedFileGateway.Service: .NET 8.0
- UnifiedFileGateway.Host: .NET 8.0 Web SDK
- UnifiedFileGateway.Client: .NET 8.0
- Contract Separation: Shared contracts in separate project for compatibility
- Async Operations: All service methods are async for scalability
- Streaming Support: MTOM encoding for large file efficiency
- Status Tracking: In-memory status tracking (consider database for production)
- Error Handling: Comprehensive exception handling and logging
Potential improvements for production use:
- Database Integration: Persistent file status tracking
- Multiple Antivirus Support: Integration with other antivirus solutions (Kaspersky, Norton, etc.)
- WebSocket Notifications: Real-time status updates
- File Versioning: Support for file version management
- Compression: Automatic file compression for storage efficiency
- Monitoring: Health checks and performance metrics
- Load Balancing: Support for multiple service instances
- Advanced Threat Detection: Integration with Microsoft Defender Advanced Threat Protection (ATP)
- Quarantine Management: Automatic quarantine of suspicious files
- Scan Scheduling: Configurable scan schedules and priorities
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.
For questions or issues with this prototype, please refer to the troubleshooting section or create an issue in the project repository.