C# ASP.NET 5模板在第一次运行时崩溃
我将在VS 2015中启动一个新项目 文件->新建->项目->ASP.NET Web应用程序->ASP.NET 5模板->Web API 项目已初始化。我假设,如果我使用IIS Express运行该项目,服务将可用 它通过启动方法运行C# ASP.NET 5模板在第一次运行时崩溃,c#,asp.net-web-api,asp.net-core,C#,Asp.net Web Api,Asp.net Core,我将在VS 2015中启动一个新项目 文件->新建->项目->ASP.NET Web应用程序->ASP.NET 5模板->Web API 项目已初始化。我假设,如果我使用IIS Express运行该项目,服务将可用 它通过启动方法运行 public class Startup { public Startup(IHostingEnvironment env) { // Set up configuration sources. var bu
public class Startup
{
public Startup(IHostingEnvironment env)
{
// Set up configuration sources.
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; set; }
// 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();
}
// 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.UseIISPlatformHandler();
app.UseStaticFiles();
app.UseMvc();
}
// Entry point for the application.
public static void Main(string[] args) =>
WebApplication.Run<Startup>(args);
}
尝试打开Visual Studio管理员模式我想这取决于崩溃的原因-从您的描述中不清楚什么崩溃、何时崩溃以及如何崩溃 您可以使用
UseExceptionHandler
和UseDeveloperExceptionPage
扩展方法来配置错误处理页面。这将更详细地描述它。
如果在启动过程中发生异常,您可能需要使用UseCaptureStartupErrors
扩展方法(最近使用了CaptureStartupErrors
)。
此外,您已经启用了日志记录-日志中可能还包含一些有用的信息。如果因为登录到控制台而无法查看日志,请考虑将日志记录到文件。
如果这是IIS/IISExpress崩溃,请检查事件日志 您的运行时版本是什么 也许您可以尝试使用构建应用程序并比较文件。 就我个人而言,我更喜欢使用脚手架,因为它通常是最新的
希望这有帮助 你能分享你的project.json吗?您是否安装了
dnvm
?我喜欢你的想法,但是当我尝试使用UsedeveloperCeptionPage或其他任何一种方法时,我会遇到一个编译器错误。看起来我缺少了一个依赖项,我不知道如何诊断它。VNext没有不同的依赖项。我没有看到黄色感叹号。我查看了事件日志,但没有找到任何东西。我运行了应用程序并让它崩溃,但事件日志中没有显示任何新内容。我在所有文件夹中查找了最近的事件。要使用developerCeptionPage,您需要依赖于Microsoft.AspNet.Diagnostics
{
"version":"1.0.0-*",
"compilationOptions":{
"emitEntryPoint":true
},
"dependencies":{
"Microsoft.AspNet.IISPlatformHandler":"1.0.0-rc1-final",
"Microsoft.AspNet.Mvc":"6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel":"1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles":"1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions":"1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json":"1.0.0-rc1-final",
"Microsoft.Extensions.Logging":"1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console":"1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug":"1.0.0-rc1-final"
},
"commands":{
"web":"Microsoft.AspNet.Server.Kestrel"
},
"frameworks":{
"dnx451":{
"frameworkAssemblies":{
"System.Web":"4.0.0.0"
}
},
"dnxcore50":{
}
},
"exclude":[
"wwwroot",
"node_modules"
],
"publishExclude":[
"**.user",
"**.vspscc"
]
}