1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

.Net 6: BlazorServer の使い方

Last updated at Posted at 2022-08-08

プロジェクトの作成と実行

dotnet new blazorserver -o b01
cd b01
dotnet run

実行した時のメッセージ

$ dotnet run
ビルドしています...
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: https://localhost:7096
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5018
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development

Chrome でアクセス
image.png

Firefox でアクセス
image.png

危険を承知で実行
image.png

データの変更

Pages/Index.razor
@page "/"

<PageTitle>Index</PageTitle>

<h1>こんにちは</h1>

Welcome to your new app.

<SurveyPrompt Title="How is Blazor working for you?" />

image.png

もう少し改造

Pages/Index.razor
@page "/"

<PageTitle>Index</PageTitle>

<h1>こんにちは</h1>

<p>Welcome to your new app.</p>
@hogehoge

@code {
	String hogehoge = DateTime.Now.ToString();
}

<SurveyPrompt Title="How is Blazor working for you?" />

image.png

ポート番号の変更

次で受けるようにする
http://localhost:5000
https://localhost:5001

Properties/launchSettings.json
{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:26896",
      "sslPort": 44322
    }
  },
  "profiles": {
    "b01": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "applicationUrl": "https://localhost:5001;http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?