Chapter 5. Creating sample applications with .NET 9.0


5.1. Creating the MVC sample application

s2i-dotnetcore-ex is the default Model, View, Controller (MVC) template application for .NET.

This application is used as the example application by the .NET S2I image and can be created directly from the OpenShift UI using the Try Example link.

The application can also be created with the OpenShift client binary (oc).

Procedure

To create the sample application using oc:

  1. Add the .NET application:

    $ oc new-app dotnet:9.0-ubi8~https://github.com/redhat-developer/s2i-dotnetcore-ex#dotnet-9.0 --context-dir=app
    Copy to Clipboard Toggle word wrap
  2. Make the application accessible externally:

    $ oc expose service s2i-dotnetcore-ex
    Copy to Clipboard Toggle word wrap
  3. Obtain the sharable URL:

    $ oc get route s2i-dotnetcore-ex
    Copy to Clipboard Toggle word wrap

5.2. Creating the CRUD sample application

s2i-dotnetcore-persistent-ex is a simple Create, Read, Update, Delete (CRUD) .NET web application that stores data in a PostgreSQL database.

Procedure

To create the sample application using oc:

  1. Add the database:

    $ oc new-app postgresql-ephemeral
    Copy to Clipboard Toggle word wrap
  2. Add the .NET application:

    $ oc new-app dotnet:9.0-ubi8~https://github.com/redhat-developer/s2i-dotnetcore-persistent-ex#dotnet-9.0 --context-dir app
    Copy to Clipboard Toggle word wrap
  3. Add environment variables from the postgresql secret and database service name environment variable:

    $ oc set env dc/s2i-dotnetcore-persistent-ex --from=secret/postgresql -e database-service=postgresql
    Copy to Clipboard Toggle word wrap
  4. Make the application accessible externally:

    $ oc expose service s2i-dotnetcore-persistent-ex
    Copy to Clipboard Toggle word wrap
  5. Obtain the sharable URL:

    $ oc get route s2i-dotnetcore-persistent-ex
    Copy to Clipboard Toggle word wrap
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2026 Red Hat
Back to top