LoginSignup
0
0

More than 1 year has passed since last update.

Raspberry Pi で .Net の MVC を作成

Last updated at Posted at 2019-12-28

次のバージョンで確認しました。

$ dotnet --version
6.0.302

プロジェクトの作成

mkdir Mvc01
cd Mvc01
dotnet new mvc
$ dotnet new mvc
The template "ASP.NET Core Web App (Model-View-Controller)" was created successfully.
This template contains technologies from parties other than Microsoft, see https://aka.ms/aspnetcore/3.0-third-party-notices for details.

Processing post-creation actions...
Running 'dotnet restore' on /home/uchida/tmp/Mvc01/Mvc01.csproj...
  /home/uchida/tmp/Mvc01/Mvc01.csproj の復元が 504.67 ms で完了しました。

Restore succeeded.

次の2つのファイルを修正します。

1) localhost 以外からもアクセスできるようにします。

appsettings.Development.json
{
        "urls": "http://*:5000",
  "Logging": {
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information"
    }
  }
}
  1. 表示に日本語を入れてみます。
Views/Home/Index.cshtml
{
    ViewData["Title"] = "Home Page";
}

<div class="text-center">
    <h1 class="display-4">Welcome</h1>
    <p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
        <p> Hello Everybody!</p>
        <p> こんにちは</p>
</div>

コンパイルと実行

dotnet run

ブラウザーで  http://host:5000/ にアクセス
image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0