# DotNet Web Project Templates

# \[0\] Prep project

Create a root folder for this tutorial

```plaintext
cd ~
cd mkdir mydotnet
```

Configure nuget source repository:

```plaintext
dotnet nuget add source https://api.nuget.org/v3/index.json --name nuget.org
```

Trust the HTTPS development certificate by running the following command:

```plaintext
dotnet dev-certs https --trust
```

# \[1\] Web

create new project. change directory to the project. open the directory in vs code.

```plaintext
dotnet new web -o web1
cd web1
code .
```

Edit the appsettings.json:

```plaintext
{
  "Kestrel": {
    "Endpoints": {
      "Http": {
        "Url": "http://localhost:5000"
      },
      "Https": {
        "Url": "https://localhost:5001"
      }
    }
  },  
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*"
}
```

Run:

```plaintext
dotnet run
```

Output:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1747068486111/13359916-944a-4049-a7a2-297e6766f2a2.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1747068554785/60cf2e14-bb56-4792-a9db-5dbf3daac718.png align="center")

# \[2\] Web Api

create new project. change directory to the project. open the directory in vs code.

```plaintext
dotnet new webapi -o webapi1
cd webapi1
code .
```

Check webapi.http

```plaintext
@webapi1_HostAddress = http://localhost:5232

GET {{webapi1_HostAddress}}/weatherforecast/
Accept: application/json

###
```

Output:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1747069904989/aaedbe1d-c559-4af7-8c33-9c3305bab768.png align="center")

# \[3\] Web App

create new project. change directory to the project. open the directory in vs code.

```plaintext
dotnet new webapp -o webapp1
cd webapp1
dotnet run
```

Output:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1747070643123/f09da449-62eb-4d4c-81c4-8787c85cfa49.png align="center")

# \[4\] Web MVC App

create new project. change directory to the project. open the directory in vs code.

```plaintext
dotnet new mvc -o mvc1
cd mvc1
dotnet run
```

Output:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1747070850687/15512663-ed90-4c51-805b-0b87ce1edc28.png align="center")

# \[5\] Comparison

[DotNet Web Project Program Comparison](https://docs.google.com/document/d/1g3g8NGQrmV4ict5lJqxSKDkwN4PdU2fFjx5aUpg1j50/edit?usp=sharing)

### **Summary**

<table><tbody><tr><td colspan="1" rowspan="1"><p><strong>Project Type</strong></p></td><td colspan="1" rowspan="1"><p><strong>Use Case</strong></p></td><td colspan="1" rowspan="1"><p><strong>Key Characteristics</strong></p></td><td colspan="1" rowspan="1"><p><strong>Examples</strong></p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Static Web Apps</strong></p></td><td colspan="1" rowspan="1"><p>Simple, static content</p></td><td colspan="1" rowspan="1"><p>Fast, no server-side logic</p></td><td colspan="1" rowspan="1"><p>Portfolios, marketing sites</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Web API</strong></p></td><td colspan="1" rowspan="1"><p>Data services for clients</p></td><td colspan="1" rowspan="1"><p>RESTful, data-focused, stateless</p></td><td colspan="1" rowspan="1"><p>Microservices, mobile backends</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Web Application</strong></p></td><td colspan="1" rowspan="1"><p>User-interactive applications</p></td><td colspan="1" rowspan="1"><p>Full frontend, dynamic content</p></td><td colspan="1" rowspan="1"><p>E-commerce, CMS</p></td></tr><tr><td colspan="1" rowspan="1"><p><strong>Web MVC</strong></p></td><td colspan="1" rowspan="1"><p>Complex user interactions</p></td><td colspan="1" rowspan="1"><p>MVC pattern, structured approach</p></td><td colspan="1" rowspan="1"><p>Enterprise apps, workflows</p></td></tr></tbody></table>

  

APPENDIX:

You can change the output for web api project to be on https port.  
For example, edit launchSettings.json:

```plaintext
{
  "$schema": "http://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:37496",
      "sslPort": 44305
    }
  },
  "profiles": {
    "http": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "launchUrl": "swagger",
      "applicationUrl": "https://localhost:44300;http://localhost:5232",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "https": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "launchUrl": "swagger",
      "applicationUrl": "https://localhost:44300;http://localhost:5232",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}
```

and then, edit webapi1.http:

```plaintext
@webapi1_HostAddress = https://localhost:44300

GET {{webapi1_HostAddress}}/weatherforecast/
Accept: application/json

###
```

Output:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1747070516181/7476c1de-458d-4348-9f48-ebd0406138b0.png align="center")
