diff --git a/TaxBaik.Web/Pages/Blog/Index.cshtml.cs b/TaxBaik.Web/Pages/Blog/Index.cshtml.cs
index 2f01e80..3314546 100644
--- a/TaxBaik.Web/Pages/Blog/Index.cshtml.cs
+++ b/TaxBaik.Web/Pages/Blog/Index.cshtml.cs
@@ -25,11 +25,23 @@ public class BlogIndexModel : PageModel
public async Task OnGetAsync(int page = 1, int? categoryId = null)
{
- CurrentPage = page;
- SelectedCategoryId = categoryId;
- Categories = (await _categoryRepository.GetAllAsync()).ToList();
- var (posts, total) = await _blogService.GetPublishedPagedAsync(page, PageSize, categoryId);
- Posts = posts.ToList();
- TotalPages = (total + PageSize - 1) / PageSize;
+ try
+ {
+ CurrentPage = page;
+ SelectedCategoryId = categoryId;
+ Categories = (await _categoryRepository.GetAllAsync()).ToList();
+ var (posts, total) = await _blogService.GetPublishedPagedAsync(page, PageSize, categoryId);
+ Posts = posts.ToList();
+ TotalPages = (total + PageSize - 1) / PageSize;
+ }
+ catch (Exception ex)
+ {
+ // DB 연결 실패 시 빈 리스트로 처리
+ CurrentPage = page;
+ SelectedCategoryId = categoryId;
+ Categories = new List();
+ Posts = new List();
+ TotalPages = 0;
+ }
}
}
diff --git a/TaxBaik.Web/Pages/Contact.cshtml.cs b/TaxBaik.Web/Pages/Contact.cshtml.cs
index 614aee4..0e7822f 100644
--- a/TaxBaik.Web/Pages/Contact.cshtml.cs
+++ b/TaxBaik.Web/Pages/Contact.cshtml.cs
@@ -50,5 +50,12 @@ public class ContactModel : PageModel
ModelState.AddModelError("", ex.Message);
return Page();
}
+ catch (Exception ex)
+ {
+ // DB 연결 실패 등의 경우에도 사용자에게 성공 메시지 표시
+ // 실제 환경에서는 별도의 로깅 및 이메일 알림 필요
+ ModelState.AddModelError("", "시스템 오류가 발생했습니다. 잠시 후 다시 시도해주세요.");
+ return Page();
+ }
}
}
diff --git a/TaxBaik.Web/Pages/Index.cshtml.cs b/TaxBaik.Web/Pages/Index.cshtml.cs
index c4035f2..5e2bbe3 100644
--- a/TaxBaik.Web/Pages/Index.cshtml.cs
+++ b/TaxBaik.Web/Pages/Index.cshtml.cs
@@ -17,7 +17,15 @@ public class IndexModel : PageModel
public async Task OnGetAsync()
{
- var (posts, _) = await _blogService.GetPublishedPagedAsync(1, 3);
- RecentPosts = posts.ToList();
+ try
+ {
+ var (posts, _) = await _blogService.GetPublishedPagedAsync(1, 3);
+ RecentPosts = posts.ToList();
+ }
+ catch (Exception ex)
+ {
+ // DB 연결 실패 시 빈 리스트로 처리
+ RecentPosts = new List();
+ }
}
}
diff --git a/TaxBaik.Web/Program.cs b/TaxBaik.Web/Program.cs
index 44b4d29..6311af8 100644
--- a/TaxBaik.Web/Program.cs
+++ b/TaxBaik.Web/Program.cs
@@ -37,14 +37,21 @@ builder.Services.AddSingleton(versionInfo);
var app = builder.Build();
-// Run migrations on startup
-using (var scope = app.Services.CreateScope())
+// Run migrations on startup (non-blocking for development)
+try
{
- var connectionFactory = scope.ServiceProvider.GetRequiredService();
- var cs = builder.Configuration.GetConnectionString("Default")
- ?? throw new InvalidOperationException("Missing connection string");
- var migrationRunner = new TaxBaik.Infrastructure.Data.MigrationRunner(cs, connectionFactory);
- await migrationRunner.RunAsync();
+ using (var scope = app.Services.CreateScope())
+ {
+ var connectionFactory = scope.ServiceProvider.GetRequiredService();
+ var cs = builder.Configuration.GetConnectionString("Default")
+ ?? throw new InvalidOperationException("Missing connection string");
+ var migrationRunner = new TaxBaik.Infrastructure.Data.MigrationRunner(cs, connectionFactory);
+ await migrationRunner.RunAsync();
+ }
+}
+catch (Exception ex)
+{
+ Console.WriteLine($"⚠️ Migration warning (non-blocking): {ex.Message}");
}
app.UsePathBase("/taxbaik");
diff --git a/TaxBaik.Web/Properties/launchSettings.json b/TaxBaik.Web/Properties/launchSettings.json
index 2cd8d10..431988a 100644
--- a/TaxBaik.Web/Properties/launchSettings.json
+++ b/TaxBaik.Web/Properties/launchSettings.json
@@ -5,7 +5,7 @@
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
- "applicationUrl": "http://localhost:5012",
+ "applicationUrl": "http://localhost:5001",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
@@ -14,7 +14,7 @@
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
- "applicationUrl": "https://localhost:7012;http://localhost:5012",
+ "applicationUrl": "https://localhost:7001;http://localhost:5001",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}