0
我创建了一个ASP.NET Core应用程序,其中一些控制器工作正常。返回ASP.NET Core应用程序根目录的特定响应
路由系统的结构类似于https://something.com/api/controller。
但是,我使用的是在Azure中始终选择选项以保持Web应用程序始终处于活动状态并且不会在空闲时暂停。
问题是,每次5分钟,天青坪我的应用程序的地址https://something.com和回来了这是在我的应用分析报表,记录一个404错误。
我想知道如何处理对我的应用程序根目录的请求,并返回200 HTTP结果。
这里是我的启动类:
public class Startup
{
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
}
private IConfigurationRoot Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
services.AddSingleton<ICachingService>(e => new CachingService(Configuration["Redis:ConnectionString"]));
var loggingService = new LoggingService(Configuration["ApplicationInsights:InstrumentationKey"]);
services.AddSingleton(typeof(ILoggingService), loggingService);
}
// 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)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseMvc();
}
}
这是一个相当简单的解决方案,它实际上是一个包罗万象的路线,将匹配如果没有其他匹配。 – juunas
你可能想限制到/路径。 – Tratcher