2015-12-28 33 views
2

我想让浏览器链接工作,所以我可以在浏览器中使用web essentials工具栏。我希望看到在ASP.NET 4个项目,但这并不在为浏览器链接网页的源文件的底部注入像一些代码,似乎情况与ASP.NET 5.web essentials浏览器链接不工作在asp mvc 6项目

enter image description here

有其他人设法让这个工作?感谢先进的任何帮助。

我使用的Visual Studio 2015年更新1

我试图在管理模式下运行,我已经变成防火墙关闭,但仍然在Visual Studio浏览器链接没有连接在调试模式下运行时。

编辑

这个方法绝对是被称为

app.UseBrowserLink(); 

这NuGet包绝对是refereced Microsoft.VisualStudio.Web.BrowserLink.Loader

我试着重新安装asp.net 5 RC1和Visual Studio 2015年亲以及使用视觉工作室社区也不工作。

我试着重新安装IIS Express 10和8,这也不起作用。

这开始是一个真正的痛苦。在浏览器中使用F12可以完成这项工作,但它真的很慢且很单调,如果任何人都可以提供一些建议来尝试使这项工作变得非常棒,我觉得我已经用尽了所有的选择。

这里是我的project.json:

{ 
    "userSecretsId": "aspnet5-BusiHub.Web-ce0683d8-2598-4feb-99b6-82d6cf4e8028", 
    "version": "1.0.0-*", 
    "compilationOptions": { 
    "emitEntryPoint": true 
    }, 

    "dependencies": { 
    "EntityFramework.Commands": "7.0.0-rc1-final", 
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final", 
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final", 
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final", 
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final", 
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final", 
    "Microsoft.AspNet.Loader.IIS": "1.0.0-beta7", 
    "Microsoft.AspNet.Loader.IIS.Interop": "1.0.0-beta7", 
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final", 
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final", 
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final", 
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final", 
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final", 
    "Microsoft.AspNet.WebApi": "5.2.3", 
    "Microsoft.Extensions.CodeGenerators.Mvc": "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.Configuration.UserSecrets": "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", 
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final", 
    "System.Web.Optimization.Less": "1.3.4" 
    }, 

    "commands": { 
    "web": "Microsoft.AspNet.Server.Kestrel", 
    "ef": "EntityFramework.Commands" 
    }, 

    "frameworks": { 
    "dnx451": { 
     "frameworkAssemblies": { } 
    } 
    }, 

    "exclude": [ 
    "wwwroot", 
    "node_modules" 
    ], 

    "publishExclude": [ 
    "**.user", 
    "**.vspscc" 
    ], 

    "scripts": { 
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ] 
    } 
} 

这里是我的startup.cs

public class Startup 
{ 
    public Startup(IHostingEnvironment env) 
    { 
     // Set up configuration sources. 
     var builder = new ConfigurationBuilder() 
      .AddJsonFile("appsettings.json") 
      .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true); 

     if (env.IsDevelopment()) 
     { 
      // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 
      builder.AddUserSecrets(); 
     } 

     builder.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.AddEntityFramework() 
      .AddSqlServer() 
      .AddDbContext<ApplicationDbContext>(options => 
       options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"])); 

     services.AddIdentity<ApplicationUser, IdentityRole>() 
      .AddEntityFrameworkStores<ApplicationDbContext>() 
      .AddDefaultTokenProviders(); 

     services.AddMvc(); 

     // Add application services. 
     services.AddTransient<IEmailSender, AuthMessageSender>(); 
     services.AddTransient<ISmsSender, AuthMessageSender>(); 

     services.AddTransient<ApplicationDbContextInitializer>(); 
    } 

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 
    public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, ApplicationDbContextInitializer dbContextInitializer) 
    { 
     loggerFactory.AddConsole(Configuration.GetSection("Logging")); 
     loggerFactory.AddDebug(); 

     if (env.IsDevelopment()) 
     { 
      // Allow updates to your files in Visual Studio to be shown in the browser. You can use the Refresh 
      // browser link button in the Visual Studio toolbar or Ctrl+Alt+Enter to refresh the browser. 
      app.UseBrowserLink(); 

      app.UseDeveloperExceptionPage(); 
      app.UseDatabaseErrorPage(); 
     } 
     else 
     { 
      app.UseExceptionHandler("/Home/Error"); 

      // For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859 
      try 
      { 
       using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>() 
        .CreateScope()) 
       { 
        serviceScope.ServiceProvider.GetService<ApplicationDbContext>() 
         .Database.Migrate(); 
       } 
      } 
      catch { } 
     } 

     app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear()); 

     app.UseStaticFiles(); 

     app.UseIdentity(); 

     // To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715 

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

     // Seed the database with sample data - admin roles, admin users etc 
     await dbContextInitializer.InitializeDataAsync(); 
    } 

    // Entry point for the application. 
    public static void Main(string[] args) => WebApplication.Run<Startup>(args); 
} 

更新

我安装了镀铬livereload插件和配置livereload如下在vendettamit的评论中所建议的一样。当我修改我的CSS/Less文件时,Chrome浏览器正在更新。由于浏览器链接不工作,我仍然缺乏Web Essentials设计和检查工具,但我希望这将在将来更新ASP.NET框架和/或Visual Studio时发生变化。

我的一饮而尽脚本,如果任何人碰到这个同样的问题绊倒:

/// <binding BeforeBuild='min, less' Clean='clean' /> 
"use strict"; 

var gulp = require("gulp"), 
    rimraf = require("rimraf"), 
    concat = require("gulp-concat"), 
    cssmin = require("gulp-cssmin"), 
    uglify = require("gulp-uglify"), 
    less = require("gulp-less"), 
    livereload = require("gulp-livereload"); 

var project = require('./project.json'); 

var paths = { 
    webroot: "./wwwroot/" 
}; 

paths.js = paths.webroot + "js/**/*.js"; 
paths.minJs = paths.webroot + "js/**/*.min.js"; 
paths.css = paths.webroot + "css/**/*.css"; 
paths.minCss = paths.webroot + "css/**/*.min.css"; 
paths.concatJsDest = paths.webroot + "js/site.min.js"; 
paths.concatCssDest = paths.webroot + "css/site.min.css"; 

gulp.task("clean:js", function (cb) { 
    rimraf(paths.webroot + "/js/site.min.js", cb); 
    rimraf(paths.webroot + "/js/site.js", cb); 
}); 

gulp.task("clean:css", function (cb) { 
    rimraf(paths.webroot + "/css/site.min.css", cb); 
    rimraf(paths.webroot + "/css/site.css", cb); 
}); 

gulp.task("clean", ["clean:js", "clean:css"]); 

gulp.task("min:js", function() { 
    return gulp.src([paths.js, "!" + paths.minJs], { base: "." }) 
     .pipe(concat(paths.concatJsDest)) 
     .pipe(uglify()) 
     .pipe(gulp.dest(".")); 
}); 

gulp.task("min:css", function() { 
    return gulp.src([paths.css, "!" + paths.minCss]) 
     .pipe(concat(paths.concatCssDest)) 
     .pipe(cssmin()) 
     .pipe(gulp.dest(".")); 
}); 

gulp.task("min", ["min:js", "min:css"]); 

gulp.task("less", ["clean:css"], function() { 
    return gulp.src('Styles/*.less') 
     .pipe(concat('site.less')) 
     .pipe(less()) 
     .pipe(gulp.dest(paths.webroot + '/css')) 
     .pipe(livereload()); 
}); 

gulp.task("scripts", ["clean:js"], function() { 
    return gulp.src('Scripts/*.js') 
     .pipe(concat('site.js')) 
     .pipe(gulp.dest(paths.webroot + '/js')); 
}); 

gulp.task("all", ["less", "scripts"]); 

gulp.task('watch', function() { 
    livereload.listen(); 
    gulp.watch('styles/*less', ['less']); 
}); 
+0

我不确定实时刷新是否附带RC版本。有一个[问题](https://github.com/aspnet/Tooling/issues/213)解决了浏览器链接的类似问题。虽然你可以尝试[this](https://github.com/vohof/gulp-livereload) – vendettamit

+0

你也可以尝试给定的解决方案[这里](http://stackoverflow.com/questions/33034169/live-reload -with-asp-net-5),但看起来像是手动刷新。 – vendettamit

+1

谢谢,生病肯定会尝试并获得设置。这比使用F12窗口要快很多。我喜欢使用Web Essentials的原因是因为设计和检查工具栏上需要连接浏览器链接。出于某种原因,我无法得到这个工作? –

回答

1

我不知道,如果现场重装附带RC版本。有一个问题解决了浏览器链接的类似问题。意思是,虽然你可以尝试this铬插件实时重新加载。

您也可以尝试给定的解决方案here,但看起来像是手动刷新。

相关问题