This will wire up the `WeatherClient` to use the correct URL for the `backend` service.
@ -148,16 +151,20 @@ Now that we have two applications running, let's make them communicate. By defau
6. Add a `Forecasts` property to the `Index` page model under `Pages\Index.cshtml.cs` in the `frontend` project.
```C#
...
public WeatherForecast[] Forecasts { get; set; }
...
```
Change the `OnGet` method to take the `WeatherClient` to call the `backend` service and store the result in the `Forecasts` property:
```C#
...
public async Task OnGet([FromServices]WeatherClient client)
{
Forecasts = await client.GetWeatherAsync();
}
...
```
7. Change the `Index.cshtml` razor view to render the `Forecasts` property in the razor page:
@ -201,8 +208,81 @@ Now that we have two applications running, let's make them communicate. By defau
8. Run the project with [`tye run`](/docs/reference/commandline/tye-run.md) and the `frontend` service should be able to successfully call the `backend` service!
When you visit the `frontend` service you should see a table of weather data. This data was produced randomly in the `backend` service. The fact that you're seeing it in a web UI in the `frontend` means that the services are able to communicate.
When you visit the `frontend` service you should see a table of weather data. This data was produced randomly in the `backend` service. The fact that you're seeing it in a web UI in the `frontend` means that the services are able to communicate. Unfortunately, this doesn't work out of the box on Linux
right now due to how self-signed certificates are handled, please see the workaround [below](#troubleshooting)
## Next Steps
Now that you are able to run a multi-project application with [`tye run`](/docs/reference/commandline/tye-run.md), move on to [the next step (deploy)](01_deploy.md) to learn how to deploy this application to Kubernetes.
## Troubleshooting
### Certificate is invalid exception on Linux
`dotnet dev-certs ...` doesn't fully work on Linux so you need to generate and trust your own certificate.
#### Generate the certificate
```sh
# See https://stackoverflow.com/questions/55485511/how-to-run-dotnet-dev-certs-https-trust
# for more details
cat <<EOF> localhost.conf
[req]
default_bits = 2048
default_keyfile = localhost.key
distinguished_name = req_distinguished_name
req_extensions = req_ext
x509_extensions = v3_ca
[req_distinguished_name]
commonName = Common Name (e.g. server FQDN or YOUR name)