ASP.NET CORE WEB API DEMO 01
2021-02-09 21:21
标签:form action adr ini XML request enc asp service ASP.NET CORE WEB API DEMO 01 标签:form action adr ini XML request enc asp service 原文地址:https://www.cnblogs.com/xiaowangzhi/p/8542968.htmlusing System;
using System.Collections.Concurrent;
using System.Collections.Generic;
namespace Demo.Models
{
public class BookChapter
{
public Guid Id { get; set; }
public int Number { get; set; }
public string Title { get; set; }
public int Pages { get; set; }
}
public interface IBookChaptersRepository
{
void Init();
IEnumerable
using System;
using System.Collections.Generic;
using Demo.Models;
using Microsoft.AspNetCore.Mvc;
namespace Demo.Controllers
{
[Produces("application/json", ("application/xml"))]
[Route("api/[controller]")]
public class BookChaptersController : Controller
{
private readonly IBookChaptersRepository _repository;
public BookChaptersController(IBookChaptersRepository bookChaptersRepository)
{
_repository = bookChaptersRepository;
}
// GET api/bookchapters
[HttpGet]
public IEnumerable
using Demo.Models;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace Demo
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().AddXmlSerializerFormatters();
IBookChaptersRepository repos = new BookChaptersRepository();
repos.Init();
services.AddSingleton(repos);
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseMvc();
}
}
}
文章标题:ASP.NET CORE WEB API DEMO 01
文章链接:http://soscw.com/index.php/essay/53274.html