ASP.NET Core Web API - html ファイルの利用
ASP.NET Core Web API で html ファイルを利用(表示)する方法です。
Startup.cs ファイルの Configure メソッドに、app.UseStaticFiles() を呼び出します。すると、wwwroot フォルダ配下の html ファイルを表示できるようになります。
public class Startup{ ...
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); }
app.UseHttpsRedirection(); app.UseMvc(); app.UseStaticFiles(); //追加 }}
💬 コメント