AI Skill Report Card
Developing Aspnet Mvc Websites
ASP.NET MVC Web Development
Quick Start
Create a new ASP.NET MVC project with essential components:
CSHARP// Models/Product.cs public class Product { public int Id { get; set; } public string Name { get; set; } public decimal Price { get; set; } public DateTime CreatedAt { get; set; } } // Controllers/ProductController.cs public class ProductController : Controller { private readonly ApplicationDbContext _context; public ProductController(ApplicationDbContext context) { _context = context; } public async Task<IActionResult> Index() { var products = await _context.Products.ToListAsync(); return View(products); } [HttpPost] public async Task<IActionResult> Create(Product product) { if (ModelState.IsValid) { _context.Products.Add(product); await _context.SaveChangesAsync(); return RedirectToAction("Index"); } return View(product); } }
Recommendation▾
Add database configuration and Entity Framework setup in Quick Start - currently jumps to using _context without showing how to create it
Workflow
Progress:
- Set up project structure (Models, Views, Controllers)
- Configure database context and connection string
- Create models with data annotations
- Implement controllers with action methods
- Design views with Razor syntax
- Add client-side validation and styling
- Configure routing and dependency injection
- Test functionality and error handling
1. Project Setup
- Create ASP.NET Core MVC project
- Install necessary NuGet packages (Entity Framework, etc.)
- Configure appsettings.json with connection strings
2. Database Layer
- Create DbContext class
- Define entity models with proper relationships
- Configure Entity Framework migrations
- Seed initial data
3. Controller Implementation
- Implement CRUD operations
- Add input validation and error handling
- Use async/await for database operations
- Implement proper HTTP status codes
4. View Development
- Create strongly-typed views
- Implement responsive layouts
- Add client-side validation with jQuery
- Use partial views for reusable components
5. Frontend Integration
- Configure CSS frameworks (Bootstrap)
- Implement JavaScript functionality
- Add AJAX calls for dynamic updates
- Optimize for mobile responsiveness
Recommendation▾
Include concrete input/output examples showing actual HTTP requests/responses, form submissions, or database queries with results
Examples
Example 1: Complete CRUD Controller Input: Need user management functionality Output:
CSHARPpublic class UserController : Controller { public async Task<IActionResult> Index() { return View(await _context.Users.ToListAsync()); } public IActionResult Create() => View(); [HttpPost] [ValidateAntiForgeryToken] public async Task<IActionResult> Create([Bind("Name,Email")] User user) { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); } return View(user); } public async Task<IActionResult> Edit(int? id) { if (id == null) return NotFound(); var user = await _context.Users.FindAsync(id); return user == null ? NotFound() : View(user); } }
Example 2: Razor View with Form Input: Create product entry form Output:
HTML@model Product <form asp-action="Create" method="post"> <div class="form-group"> <label asp-for="Name" class="control-label"></label> <input asp-for="Name" class="form-control" /> <span asp-validation-for="Name" class="text-danger"></span> </div> <div class="form-group"> <label asp-for="Price" class="control-label"></label> <input asp-for="Price" class="form-control" type="number" step="0.01" /> <span asp-validation-for="Price" class="text-danger"></span> </div> <button type="submit" class="btn btn-primary">Create</button> </form>
Recommendation▾
Provide a complete minimal working example in Quick Start that someone could copy-paste and run immediately
Best Practices
- Use dependency injection for services and DbContext
- Implement proper error handling with try-catch blocks
- Apply data annotations for validation
- Use async/await for all database operations
- Follow naming conventions (PascalCase for public members)
- Implement proper security (ValidateAntiForgeryToken, authorization)
- Use strongly-typed views and avoid ViewBag when possible
- Implement proper logging throughout the application
- Keep controllers thin, move business logic to services
- Use Entity Framework migrations for database changes
Common Pitfalls
- Don't expose DbContext directly in views
- Don't ignore ModelState validation in POST actions
- Don't forget to dispose of resources (use using statements)
- Don't mix synchronous and asynchronous code
- Don't return sensitive data in JSON responses
- Don't forget Cross-Site Request Forgery (CSRF) protection
- Don't use string concatenation for SQL queries (use LINQ/EF)
- Don't forget to handle null reference exceptions
- Don't put business logic in controllers
- Don't forget to implement proper error pages (404, 500)