Mac Status Bar App Tutorial

-->

By Rick Anderson

This is the first tutorial of a series that teaches the basics of building an ASP.NET Core Razor Pages web app.

For a more advanced introduction aimed at developers who are familiar with controllers and views, see Introduction to Razor Pages.

At the end of the series, you'll have an app that manages a database of movies.

Aug 04, 2018  Menu Bar apps are little, but they play a big part of my workflow. Today's video is about my top 20 favorite menu bar apps for the Mac OS (sorry to all the PC users out there) Remember to. In this Menu Bar App tutorial you will learn how to present a menu and a popover that shows quotes from famous people. Sep 30, 2019  If you download it from the Mac App Store, then updating Xcode becomes really easy since you can just download and install the update through the store. The Xcode Status Bar. A app for streaming a Audio using RTSP from device and it recieved at the client end like Mac pc where we developing an app you have any tutorial for this!

View or download sample code (how to download).

In this tutorial, you:

  • Create a Razor Pages web app.
  • Run the app.
  • Examine the project files.

At the end of this tutorial, you'll have a working Razor Pages web app that you'll build on in later tutorials.

Prerequisites

  • Visual Studio 2019 16.4 or later with the ASP.NET and web development workload

The Visual Studio Code instructions use the .NET Core CLI for ASP.NET Core development functions such as project creation. You can follow these instructions on any platform (macOS, Linux, or Windows) and with any code editor. Minor changes may be required if you use something other than Visual Studio Code. For more information on installing Visual Studio Code on macOS, see Visual Studio Code on macOS.

Create a Razor Pages web app

  • From the Visual Studio File menu, select New > Project.

  • Create a new ASP.NET Core Web Application and select Next.

  • Name the project RazorPagesMovie. It's important to name the project RazorPagesMovie so the namespaces will match when you copy and paste code.

  • Select ASP.NET Core 3.1 in the dropdown, Web Application, and then select Create.

The following starter project is created:

Mac Status Bar App Tutorial Download

  • Open the integrated terminal.

  • Change to the directory (cd) which will contain the project.

  • Run the following commands:

    • The dotnet new command creates a new Razor Pages project in the RazorPagesMovie folder.
    • The code command opens the RazorPagesMovie folder in the current instance of Visual Studio Code.
  • After the status bar's OmniSharp flame icon turns green, a dialog asks Required assets to build and debug are missing from 'RazorPagesMovie'. Add them? Select Yes.

    A .vscode directory, containing launch.json and tasks.json files, is added to the project's root directory.

  • Select File > New Solution.

  • In Visual Studio for Mac earlier than version 8.6, select .NET Core > App > Web Application > Next. In version 8.6 or later, select Web and Console > App > Web Application > Next.

  • In the Configure your new Web Application dialog:

    • Confirm that Authentication is set to No Authentication.
    • If presented an option to select a Target Framework, select the latest 3.x version.

    Select Next.

  • Name the project RazorPagesMovie, and then select Create.

Run the app

  • Press Ctrl+F5 to run without the debugger.

    Visual Studio displays the following dialog:

    Select Yes if you trust the IIS Express SSL certificate.

    The following dialog is displayed:

    Select Yes if you agree to trust the development certificate.

    Visual Studio starts IIS Express and runs the app. The address bar shows localhost:port# and not something like example.com. That's because localhost is the standard hostname for the local computer. Localhost only serves web requests from the local computer. When Visual Studio creates a web project, a random port is used for the web server.

  • Trust the HTTPS development certificate by running the following command:

    The preceding command doesn't work on Linux. See your Linux distribution's documentation for trusting a certificate.

    The preceding command displays the following dialog:

  • Select Yes if you agree to trust the development certificate.

    See Trust the ASP.NET Core HTTPS development certificate for more information.

  • Press Ctrl-F5 to run without the debugger.

    Visual Studio Code starts Kestrel, launches a browser, and navigates to http://localhost:5001. The address bar shows localhost:port# and not something like example.com. That's because localhost is the standard hostname for local computer. Localhost only serves web requests from the local computer.

Visual Studio for Mac displays the following popup:

Select Yes if you trust the development certificate.

The following dialog is displayed:

Enter your password and select OK

Select Yes if you agree to trust the development certificate.

See Trust the ASP.NET Core HTTPS development certificate for more information

  • From Visual Studio, press Opt-Cmd-Return to run without the debugger. Alternatively, navigate to the menu bar and go to Run>Start Without Debugging.

    Visual Studio starts Kestrel, launches a browser, and navigates to http://localhost:5001.

Examine the project files

Here's an overview of the main project folders and files that you'll work with in later tutorials.

Pages folder

Contains Razor pages and supporting files. Each Razor page is a pair of files:

  • A .cshtml file that contains HTML markup with C# code using Razor syntax.
  • A .cshtml.cs file that contains C# code that handles page events.

Supporting files have names that begin with an underscore. For example, the _Layout.cshtml file configures UI elements common to all pages. This file sets up the navigation menu at the top of the page and the copyright notice at the bottom of the page. For more information, see Layout in ASP.NET Core.

wwwroot folder

Contains static files, such as HTML files, JavaScript files, and CSS files. For more information, see Static files in ASP.NET Core.

appSettings.json

Contains configuration data, such as connection strings. For more information, see Configuration in ASP.NET Core.

Mac Status Bar App Tutorial 2017

Program.cs

Contains the entry point for the program. For more information, see .NET Generic Host.

Startup.cs

Contains code that configures app behavior. For more information, see App startup in ASP.NET Core.

Next steps

Advance to the next tutorial in the series:

This is the first tutorial of a series. The series teaches the basics of building an ASP.NET Core Razor Pages web app.

For a more advanced introduction aimed at developers who are familiar with controllers and views, see Introduction to Razor Pages.

At the end of the series, you'll have an app that manages a database of movies.

View or download sample code (how to download).

In this tutorial, you:

  • Create a Razor Pages web app.
  • Run the app.
  • Examine the project files.

At the end of this tutorial, you'll have a working Razor Pages web app that you'll build on in later tutorials.

Prerequisites

  • Visual Studio 2019 with the ASP.NET and web development workload

Warning

If you use Visual Studio 2017, see dotnet/sdk issue #3124 for information about .NET Core SDK versions that don't work with Visual Studio.

The Visual Studio Code instructions use the .NET Core CLI for ASP.NET Core development functions such as project creation. You can follow these instructions on any platform (macOS, Linux, or Windows) and with any code editor. Minor changes may be required if you use something other than Visual Studio Code.

Create a Razor Pages web app

  • From the Visual Studio File menu, select New > Project.

  • Create a new ASP.NET Core Web Application and select Next.

  • Name the project RazorPagesMovie. It's important to name the project RazorPagesMovie so the namespaces will match when you copy and paste code.

  • Select ASP.NET Core 2.2 in the dropdown, Web Application, and then select Create.

The following starter project is created:

  • Open the integrated terminal.

  • Change to the directory (cd) which will contain the project.

  • Run the following commands:

    • The dotnet new command creates a new Razor Pages project in the RazorPagesMovie folder.
    • The code command opens the RazorPagesMovie folder in the current instance of Visual Studio Code.
  • After the status bar's OmniSharp flame icon turns green, a dialog asks Required assets to build and debug are missing from 'RazorPagesMovie'. Add them? Select Yes.

    A .vscode directory, containing launch.json and tasks.json files, is added to the project's root directory.

  • Select File > New Solution.
  • In Visual Studio for Mac earlier than version 8.6, select .NET Core > App > Web Application > Next. In version 8.6 or later, select Web and Console > App > Web Application > Next.

  • In the Configure your new Web Application dialog:

    • Confirm that Authentication is set to No Authentication.
    • If presented an option to select a Target Framework, select the latest 2.x version.

    Select Next.

  • Name the project RazorPagesMovie, and then select Create.

Run the app

  • Press Ctrl+F5 to run without the debugger.

    Visual Studio displays the following dialog:

    Select Yes if you trust the IIS Express SSL certificate.

    The following dialog is displayed:

    Select Yes if you agree to trust the development certificate.

    Visual Studio starts IIS Express and runs the app. The address bar shows localhost:port# and not something like example.com. That's because localhost is the standard hostname for the local computer. Localhost only serves web requests from the local computer. When Visual Studio creates a web project, a random port is used for the web server.

  • On the app's home page, select Accept to consent to tracking.

    This app doesn't track personal information, but the project template includes the consent feature in case you need it to comply with the European Union's General Data Protection Regulation (GDPR).

    The following image shows the app after you give consent to tracking:

  • Trust the HTTPS development certificate by running the following command:

    The preceding command doesn't work on Linux. See your Linux distribution's documentation for trusting a certificate.

    The preceding command displays the following dialog:

  • Select Yes if you agree to trust the development certificate.

    See Trust the ASP.NET Core HTTPS development certificate for more information.

Mac
  • Press Ctrl-F5 to run without the debugger.

    Visual Studio Code starts Kestrel, launches a browser, and navigates to http://localhost:5001. The address bar shows localhost:port# and not something like example.com. That's because localhost is the standard hostname for local computer. Localhost only serves web requests from the local computer.

  • On the app's home page, select Accept to consent to tracking.

    This app doesn't track personal information, but the project template includes the consent feature in case you need it to comply with the European Union's General Data Protection Regulation (GDPR).

    The following image shows the app after you give consent to tracking:

Visual Studio for Mac displays the following popup:

Select Yes if you trust the development certificate.

The following dialog is displayed:

Enter your password and select OK

Select Yes if you agree to trust the development certificate.

See Trust the ASP.NET Core HTTPS development certificate for more information

  • Press Cmd-Opt-F5 to run without the debugger.

    Visual Studio starts Kestrel, launches a browser, and navigates to http://localhost:5001.

  • On the app's home page, select Accept to consent to tracking.

    This app doesn't track personal information, but the project template includes the consent feature in case you need it to comply with the European Union's General Data Protection Regulation (GDPR).

    The following image shows the app after you give consent to tracking:

Examine the project files

Here's an overview of the main project folders and files that you'll work with in later tutorials.

Pages folder

Contains Razor pages and supporting files. Each Razor page is a pair of files:

  • A .cshtml file that contains HTML markup with C# code using Razor syntax.
  • A .cshtml.cs file that contains C# code that handles page events.

Supporting files have names that begin with an underscore. For example, the _Layout.cshtml file configures UI elements common to all pages. This file sets up the navigation menu at the top of the page and the copyright notice at the bottom of the page. For more information, see Layout in ASP.NET Core.

wwwroot folder

Contains static files, such as HTML files, JavaScript files, and CSS files. For more information, see Static files in ASP.NET Core.

appSettings.json

Contains configuration data, such as connection strings. For more information, see Configuration in ASP.NET Core.

Program.cs

Contains the entry point for the program. For more information, see .NET Generic Host.

Startup.cs

Contains code that configures app behavior, such as whether it requires consent for cookies. For more information, see App startup in ASP.NET Core.

Additional resources

Next steps

Advance to the next tutorial in the series: