"Replace OWIN self-hosting with WebView2 virtual hosting" -m "-

Remove OWIN server implementation (StaticFileServer, Startup)" -m "- Implement
    WebView2 SetVirtualHostNameToFolderMapping in Frm_WebManual" -m "- Remove all
   OWIN NuGet packages from packages.config and .vbproj" -m "- Add comprehensive
   guide document (WEBVIEW2_VIRTUAL_HOSTING.md)" -m "- Mark legacy OWIN files as
   deprecated
This commit is contained in:
2025-12-01 20:55:42 +09:00
parent 1d6c51df3b
commit 132ddc6495
12 changed files with 155 additions and 1057 deletions

View File

@@ -4,27 +4,50 @@ Imports Microsoft.Web.WebView2.Core
Public Class Frm_WebManual
Public Sub Navigate(url As String)
Try
If WebView21 IsNot Nothing AndAlso WebView21.CoreWebView2 IsNot Nothing Then
WebView21.CoreWebView2.Navigate(url)
End If
Catch ex As Exception
MessageBox.Show("웹페이지 이동 중 오류가 발생했습니다: " & ex.Message,
"오류", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Async Sub Frm_WebManual_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
' WebView2 초기화 (Runtime이 없으면 자동 다운로드)
' WebView2 초기화
Await InitializeWebView2Async()
' 로컬 웹서버 페이지 로드
If WebView21.CoreWebView2 IsNot Nothing Then
WebView21.CoreWebView2.Navigate("http://localhost:58123/")
End If
Try
' 가상 호스팅 설정
If WebView21.CoreWebView2 Is Nothing Then
Return
End If
' wwwroot 경로 확인
Dim _wwwrootPath As String = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "wwwroot")
If String.IsNullOrEmpty(_wwwrootPath) Then
_wwwrootPath = Path.Combine(Application.StartupPath, "wwwroot")
End If
' 디렉토리가 없으면 생성
If Not Directory.Exists(_wwwrootPath) Then
Directory.CreateDirectory(_wwwrootPath)
End If
' 가상 호스트 매핑 설정
' https://eco2.local/ -> 로컬 폴더 매핑
WebView21.CoreWebView2.SetVirtualHostNameToFolderMapping(
"eco2.local",
_wwwrootPath,
CoreWebView2HostResourceAccessKind.Allow)
If WebView21 IsNot Nothing AndAlso WebView21.CoreWebView2 IsNot Nothing Then
' 가상 호스트 URL 사용
Dim url As String = "https://eco2.local/index.html"
WebView21.CoreWebView2.Navigate(url)
End If
Catch ex As Exception
MessageBox.Show("웹페이지 이동 중 오류가 발생했습니다: " & ex.Message,
"오류", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Catch ex As Exception
MessageBox.Show("웹페이지 로드 중 오류가 발생했습니다: " & ex.Message,
@@ -62,4 +85,5 @@ Public Class Frm_WebManual
End Try
End Function
End Class