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 件のコメント:

コメントを投稿

Gitを用いた開発の流れ

Gitを用いた開発の流れ 1.Clone 共有リポジトリから、ローカルへコピー 2.ファイル編集 3.add 編集したファイルをcommit対象として登録 4.commit ローカルリポジトリへ反映 5.push ローカルリポジトリから、共有リポジトリへ...