2017-02-08 3 views
1

Der Debugger in der C# Erweiterung für Visual Studio-Code scheint zu ändern, wie Routing funktioniert; Wenn ich die App mit dotnet run starte, ist alles in Ordnung, aber wenn ich den Debugger verwende, werden bestimmte Routen ignoriert.vscode C# Debugger fehlende Routen in asp.net mvc Kern App

Antwort mit Dotnet Lauf

Response using dotnet run

Antwort C# Debugger (fallende bis hin zu einem app.Run (...);)

Response using c# debugger

so gut ich kann sagen, Es gibt nichts in der Konfiguration, das dies beeinflussen sollte.

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}" 
     }] 
    } 

Jede Hilfe sehr geschätzt.

Antwort

0

Das Problem war mit der launch.json, die die zu debuggende Datei angibt. Ich hatte das Projekt nach dem Start auf 1.1 geändert. JSON wurde generiert und es gab immer noch die 1.0 DLL an.