2017-02-08 8 views
1

Отладчик в расширении C# для визуального кода студии, похоже, изменяет работу маршрутизации; если я запустил приложение с запуском dotnet, все хорошо, но если я использую отладчик, некоторые маршруты игнорируются.vscode C# отладчик отсутствует маршруты в asp.net mvc core app

Response с помощью DotNet запустить

Response using dotnet run

Ответ с использованием C# отладчик (проваливаться к app.Run (...);)

Response using c# debugger

Насколько я могу сказать , в конфигурации нет ничего, что должно повлиять на это.

Program.cs

public class Program 
{ 
    public static void Main(string[] args) 
    { 
     var host = new WebHostBuilder() 
      .CaptureStartupErrors(true) 
      .UseSetting("detailedErrors","true") 
      .UseKestrel() 
      .UseContentRoot(Directory.GetCurrentDirectory()) 
      .UseIISIntegration() 
      .UseStartup<Startup>() 
      .Build(); 

     host.Run(); 
    } 
} 

Startup.cs

public class Startup 
{ 
    public IConfigurationRoot Configuration { get; } 

    public Startup(IHostingEnvironment env) 
    { 
     var builder = new ConfigurationBuilder() 
      .SetBasePath(env.ContentRootPath) 
      .AddJsonFile("appsettings.json", true) 
      .AddJsonFile($"appsettings.{env.EnvironmentName}.json", true) 
      .AddEnvironmentVariables(); 

     Configuration = builder.Build(); 
    } 

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 
    public void ConfigureServices(IServiceCollection services) 
    { 
     services.AddEntityFrameworkSqlServer()  
      .AddDbContext<MyDbContext>(options =>       
       options.UseSqlServer(Configuration.GetConnectionString("MyDbContext")) 
       ); 

     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 
      .AddDebug() 
      .AddConsole() 
      .AddAzureWebAppDiagnostics(); 

     var logger = loggerFactory.CreateLogger<Startup>(); 

     logger.LogInformation(1, "Logging in Configure"); 
     logger.LogInformation(1, $"ConnectionString: {Configuration.GetConnectionString("MyDbContext")}"); 

     if (env.IsDevelopment()) 
     { 
      app.UseDeveloperExceptionPage(); 
     } 

     app.UseStaticFiles();  

     app.UseMvc(routes => { 
      routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}"); 
     }); 

     app.Run(async context => { 
      await context.Response.WriteAsync($"Hello World: The current environment is {env.EnvironmentName}, the current value is {Configuration["MyEnvironment"]}"); 
     }); 
    } 
} 

launch.json

{ 
    "version": "0.2.0", 
    "configurations": [ 
     { 
     "name": ".NET Core Launch (web)", 
     "type": "coreclr", 
     "request": "launch", 
     "preLaunchTask": "build", 
     "program": "${workspaceRoot}\\src\\web\\bin\\Debug\\netcoreapp1.0\\web.dll", 
     "args": [], 
     "cwd": "${workspaceRoot}\\src\\web", 
     "stopAtEntry": false, 
     "internalConsoleOptions": "openOnSessionStart", 
     "launchBrowser": { 
      "enabled": true, 
      "args": "${auto-detect-url}", 
      "windows": { 
       "command": "cmd.exe", 
       "args": "/C start ${auto-detect-url}" 
       }, 
      "osx": { 
       "command": "open" 
       }, 
      "linux": { 
       "command": "xdg-open" 
       } 
      }, 
     "env": { 
      "ASPNETCORE_ENVIRONMENT": "Development" 
      }, 
     "sourceFileMap": { 
      "/Views": "${workspaceRoot}/Views" 
      } 
     }, 
     { 
     "name": ".NET Core Attach", 
     "type": "coreclr", 
     "request": "attach", 
     "processId": "${command.pickProcess}" 
     }] 
    } 

Любая помощь приветствуется.

ответ

0

Проблема была в файле launch.json, который указывает файл для отладки. Я изменил проект на целевой 1.1 после запуска launch.json и все еще указывал 1.0 dll.