Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Creating your first ASP.NET MVC web site on RHEL

February 3, 2017
Don Schenck
Related topics:
.NETLinux
Related products:
Red Hat Enterprise Linux

Share:

    Follow this blog post, and within minutes you will have an ASP.NET MVC website running on Red Hat Enterprise Linux (RHEL). Yes, I'm talking to you, Windows .NET developer; you're about to double your OS skillset. Let's do this.

    I'm going to start with some assumptions:

    1. You are running Windows.
    2. You are not running Linux.

    Based on those two assumptions, we're going to:

    1. Install a RHEL Virtual Machine (VM) on your Windows PC.
    2. Start and run the VM.
    3. Install .NET on your VM.
    4. Create an ASP.NET MVC website.

    Install a RHEL VM on your Windows PC

    The quickest and most useful way to get Linux running in a VM is to download and install the Red Hat Development Suite. Sure, it has some pieces you probably don't want -- Java-related stuff -- but the remaining bits are great. You'll get a RHEL VM with kubernetes, Linux container, and OpenShift added in for container development.

    (Such a deal; you're not only going to have an ASP.NET MVC website running in a few minutes, but you're also going to have all you need to start creating and using containers. Hey man ... we .NET developers need to look out for each other, am I right?)

    Run the install and use the default installation path. You can change it if you wish, but you'll need to use that path in the next step.

    Start and Run  the VM

    Open PowerShell and run some commands. Here's the list of commands you'll need:
    cd C:\DevelopmentSuite\cdk\components\rhel\rhel-ose\
    vagrant up

    That's it! That's the list! Move it into the proper directory and run vagrant up. You'll use this magic every time you want to start your RHEL VM. Pretty easy, eh?

    When the VM is starting, you'll be asked if you want to register the system now. Answer 'y' and then use your Red Hat account credentials to register. Registering means, you have a proper, valid, full-fledged installation of RHEL; complete with the subscriptions you need to be a productive RHEL developer.

    Install .NET on your VM

    At the command line, use the following command to use ssh to get into your RHEL VM:

    vagrant ssh

    The installation automatically sets up the public and private keys needed for security. For the record, both user id and password is 'vagrant'.

    Now you're at a RHEL command prompt.

    Now we can install .NET. Note that this is .NET Core 1.1.

    First, run the command sudo subscription-manager register. If prompted for a password, it's vagrant, as mentioned earlier. If you're new to Linux, 'sudo' is like running a program "as Administrator" on Windows.

    Next, sudo subscription-manager list --available. This will give you the Pool ID you need next.

    Use that Pool ID in the following command: sudo subscription-manager attach --pool={pool id from previous step}

    Next, sudo subscription-manager repos --enable=rhel-7-server-dotnet-rpms

    sudo yum install -y scl-utils

    sudo yum install -y rh-dotnetcore11

    scl enable rh-dotnetcore11 bash

    Finally, prove the installation by running dotnet.

    These instructions, with more explanation, can be found at the Red Hat .NET installation web page.

    Create an ASP.NET MVC website

    Create a directory for your new site and move the following into it.

    mkdir mvc

    cd mvc

    Now to create the website.

    dotnet new --type web

    dotnet restore

    dotnet run

    That's it; you now have a basic ASP.NET MVC website running on your RHEL VM.

    There's a tiny issue: You see, the generated code is meant to run on localhost:5000. Well, localhost is the VM, so you won't be able to view the website outside of the VM.

    Before we change any code, open another PowerShell session, navigate to your VM directory, C:\DevelopmentSuite\cdk\components\rhel\rhel-ose\, and run the vagrant ssh command to get a second VM command prompt. Now you can run cURL to see the website; use the command curl localhost:5000. You'll see the HTML for the web page.

    More: Viewing the site from outside the VM

    This is fine, but cURL isn't exactly the user experience of choice. Instead, viewing the page from a browser would be what we really want.

    Fortunately, all it takes is a change to one line of code. Unfortunately, this involves using an editor that's built into RHEL: VI. It's ... uh ... not exactly intuitive (understatement of the year right there!). In fact, it's so challenging that at this point you can just search the Internet for a "VI Cheat Sheet" and use it.

    The line of code to be changed is line 18 in the file Program.cs. Change the code from .UseStartup<Startup>() to .UseStartup<Startup>.UseUrls("http://*:5000"). The following illustrates the change:

    Now, after you start the program (using dotnet run), you can access the web page from your browser in your Windows host by using the IP address of your VM -- which is 10.1.2.2.

    So there you have it; your first ASP.NET Core MVC web site, running on RHEL. In a production environment, you'll want to put the Kestrel web server behind NGINX or Apache ... but that's another blog post.

    For additional information and articles on .NET Core visit our .NET Core web page for more on this topic.

     

    Last updated: May 26, 2022

    Recent Posts

    • How to deploy language models with Red Hat OpenShift AI

    • AI search with style: Fashion on OpenShift AI with EDB

    • What qualifies for Red Hat Developer Subscription for Teams?

    • How to run OpenAI's gpt-oss models locally with RamaLama

    • Using DNS over TLS in OpenShift to secure communications

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue