我在asp.net核心中提供静态文件时遇到问题。我真的很陌生。只是按照复数形式的教程进行操作并停留在这里。
我在wwwroot文件夹中添加了index.html,并在Json中添加了静态文件的依赖项,但似乎仍然无效。任何帮助将不胜感激。
cudaMemcpy
这是我的project.json
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace TheWorld
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseStaticFiles();
// app.Run(async (context) =>
// {
// await context.Response.WriteAsync("Hello World!");
// });
}
}
}
答案 0 :(得分:0)
为了让您的网络应用无需用户完全限定URI即可投放默认网页,请按以下方式从UseDefaultFiles
调用Startup.Configure
扩展程序。
public void Configure(IApplicationBuilder app)
{
app.UseDefaultFiles();
app.UseStaticFiles();
}
必须在UseDefaultFiles
之前调用{p> UseStaticFiles
来提供默认文件。
参考:https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files#serving-default-files