# Quick IIS Deployment Guide - Sky Art Shop

## ⚡ Simplified Deployment (5 Steps)

### Step 1: Install Prerequisites (One-Time)

**A. Enable IIS**

- Run PowerShell as Administrator
- Execute:

```powershell
cd "E:\Documents\Website Projects\Sky_Art_Shop"
.\deploy.ps1 -InstallIIS
```

- **Restart your computer**

**B. Install .NET 8.0 Hosting Bundle**

- Download from: <https://dotnet.microsoft.com/download/dotnet/8.0>
- Look for "Hosting Bundle"
- Install and **restart computer**

### Step 2: Deploy Your Site

Run PowerShell as **Administrator**:

```powershell
cd "E:\Documents\Website Projects\Sky_Art_Shop"
.\deploy.ps1 -CreateSite
```

That's it! The script handles everything:

- ✅ Publishing the application
- ✅ Creating IIS site
- ✅ Setting permissions
- ✅ Configuring firewall

### Step 3: Verify MongoDB is Running

```powershell
# Check if MongoDB is running
Get-Service -Name MongoDB* -ErrorAction SilentlyContinue

# If not running, start it
net start MongoDB
```

### Step 4: Test Locally

1. Open browser
2. Go to: <http://localhost>
3. You should see your site!

**If you get errors:**

```powershell
# Check IIS status
Get-WebSite -Name "SkyArtShop"

# Restart IIS
iisreset /restart

# Check what's using port 80
netstat -ano | findstr :80
```

### Step 5: Configure Network (For Internet Access)

**A. Set Static IP**

1. Control Panel → Network → Properties
2. Set static IP (e.g., 192.168.1.100)

**B. Router Port Forwarding**

1. Login to your router (usually 192.168.1.1)
2. Forward port 80 → your PC's IP (192.168.1.100)

**C. No-IP Client**

1. Download: <https://www.noip.com/download>
2. Install and login
3. Your site will be at: <http://your-hostname.ddns.net>

---

## 🔄 Updating Your Site

When you make changes:

```powershell
cd "E:\Documents\Website Projects\Sky_Art_Shop"
.\deploy.ps1 -UpdateOnly
```

---

## 🆘 Quick Troubleshooting

**Site won't load locally:**

```powershell
# Restart IIS
iisreset /restart

# Check site status
Get-WebSite -Name "SkyArtShop"

# If stopped, start it
Start-WebSite -Name "SkyArtShop"
```

**502.5 Error:**

- You need to install .NET 8.0 Hosting Bundle
- Restart computer after installing

**403 Forbidden:**

```powershell
# Fix permissions
icacls "C:\inetpub\wwwroot\skyartshop" /grant "IIS_IUSRS:(OI)(CI)F" /T
iisreset /restart
```

**Can't access from internet:**

- Check port forwarding on router
- Make sure No-IP DUC is running
- Test your public IP directly first

---

## 📝 Your URLs After Deployment

- **Local**: <http://localhost>
- **Local Network**: <http://192.168.1.100> (your IP)
- **Internet**: <http://your-hostname.ddns.net>

---

## ⚙️ Manual Deployment (If Script Fails)

If the automated script doesn't work, follow these steps:

### 1. Publish Application

```powershell
cd "E:\Documents\Website Projects\Sky_Art_Shop"
dotnet publish SkyArtShop.csproj -c Release -o "C:\inetpub\wwwroot\skyartshop"
```

### 2. Create IIS Site Manually

1. Open IIS Manager (search in Windows Start)
2. Right-click Sites → Add Website
3. Site name: **SkyArtShop**
4. Physical path: **C:\inetpub\wwwroot\skyartshop**
5. Port: **80**
6. Click OK

### 3. Configure Application Pool

1. Click Application Pools
2. Right-click SkyArtShop → Basic Settings
3. .NET CLR version: **No Managed Code**
4. OK

### 4. Set Permissions

```powershell
icacls "C:\inetpub\wwwroot\skyartshop" /grant "IIS_IUSRS:(OI)(CI)F" /T
icacls "C:\inetpub\wwwroot\skyartshop" /grant "IUSR:(OI)(CI)F" /T
```

### 5. Configure Firewall

```powershell
New-NetFirewallRule -DisplayName "SkyArtShop-HTTP" -Direction Inbound -Protocol TCP -LocalPort 80 -Action Allow
```

### 6. Start Site

```powershell
Start-WebSite -Name "SkyArtShop"
```

---

## 🎯 Deployment Checklist

- [ ] IIS installed
- [ ] .NET 8.0 Hosting Bundle installed
- [ ] Computer restarted after installations
- [ ] MongoDB running
- [ ] Application published to C:\inetpub\wwwroot\skyartshop
- [ ] IIS site created
- [ ] Application pool set to "No Managed Code"
- [ ] Permissions granted
- [ ] Firewall rule added
- [ ] Site accessible at <http://localhost>
- [ ] (Optional) Static IP configured
- [ ] (Optional) Router port forwarding
- [ ] (Optional) No-IP client installed

---

**For the full detailed guide, see DEPLOYMENT_GUIDE.md**
