2021年10月13日水曜日

クロニクル .NET Core ASP.NET Core Controllerを追加する

前の記事の続きです。

1.Controllerの追加


Controllerフォルダーの下に、次のようなファイル(SampleController.cs)を作成します

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using AspNetCoreSample.Models;

namespace AspNetCoreSample.Controllers
{
    public class SampleController : Controller
    {
        public string Index()
        {
            return "This is my Sample";
        }
    }
}

2.実行


> dotnet run で実行し

http://localhost:5000/Sample

にアクセスすると

This is my Sample

が表示されます





0 件のコメント:

コメントを投稿

クロニクル MacでIntelliJ

 1. IntelliJ IDEA Community Editionのダウンロードとインストール 1-1.ダウンロード: Mac用のCommunity Edition(無料版)を選択し、**.dmg**ファイルをダウンロードします。 ここからダウンロードしました。 https:...