Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# web essentials浏览器链接在asp mvc 6项目中不起作用_C#_Json_Asp.net Core_Asp.net Core Mvc_Browser Link - Fatal编程技术网

C# web essentials浏览器链接在asp mvc 6项目中不起作用

C# web essentials浏览器链接在asp mvc 6项目中不起作用,c#,json,asp.net-core,asp.net-core-mvc,browser-link,C#,Json,Asp.net Core,Asp.net Core Mvc,Browser Link,我正在尝试使浏览器链接正常工作,以便可以在浏览器中使用web essentials工具栏。我希望看到一些代码注入到页面底部,比如ASP.NET 4项目中的浏览器链接源代码,但ASP.NET 5的情况似乎并非如此 还有其他人能做到吗?谢谢你的帮助 我正在使用visual studio 2015更新1 我尝试在管理模式下运行,并关闭了防火墙,但在调试模式下运行时,visual studio中的浏览器链接中仍然没有连接 编辑 这个方法肯定被调用了 app.UseBrowserLink(); 此nu

我正在尝试使浏览器链接正常工作,以便可以在浏览器中使用web essentials工具栏。我希望看到一些代码注入到页面底部,比如ASP.NET 4项目中的浏览器链接源代码,但ASP.NET 5的情况似乎并非如此

还有其他人能做到吗?谢谢你的帮助

我正在使用visual studio 2015更新1

我尝试在管理模式下运行,并关闭了防火墙,但在调试模式下运行时,visual studio中的浏览器链接中仍然没有连接

编辑

这个方法肯定被调用了

app.UseBrowserLink();
此nuget软件包绝对是指Microsoft.VisualStudio.Web.BrowserLink.Loader

我尝试过重新安装asp.net 5 rc1和visual studio 2015 pro,还尝试过使用visual studio社区,但都不起作用

我尝试重新安装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);
}
公共类启动
{
公共启动(IHostingEnvironment环境)
{
//设置配置源。
var builder=new ConfigurationBuilder()
.AddJsonFile(“appsettings.json”)
.AddJsonFile($“appsettings.{env.EnvironmentName}.json”,可选:true);
if(env.IsDevelopment())
{
//有关使用用户机密存储的更多详细信息,请参阅http://go.microsoft.com/fwlink/?LinkID=532709
builder.AddUserSecrets();
}
builder.AddEnvironmentVariables();
Configuration=builder.Build();
}
公共IConfigurationRoot配置{get;set;}
//此方法由运行时调用。请使用此方法将服务添加到容器中。
public void配置服务(IServiceCollection服务)
{
//添加框架服务。
services.AddEntityFramework()
.AddSqlServer()文件
.AddDbContext(选项=>
使用SQLServer(配置[“数据:默认连接:连接字符串]);
服务.额外性()
.AddEntityFrameworkStores()
.AddDefaultTokenProviders();
services.AddMvc();
//添加应用程序服务。
services.AddTransient();
services.AddTransient();
services.AddTransient();
}
//此方法由运行时调用。请使用此方法配置HTTP请求管道。
公共异步无效配置(IAApplicationBuilder应用程序、IHostingEnvironment环境、ILoggerFactory loggerFactory、ApplicationDbContextInitializer dbContextInitializer)
{
loggerFactory.AddConsole(Configuration.GetSection(“Logging”);
loggerFactory.AddDebug();
if(env.IsDevelopment())
{
//允许在浏览器中显示对Visual Studio中文件的更新。您可以使用“刷新”
//Visual Studio工具栏中的浏览器链接按钮或Ctrl+Alt+Enter以刷新浏览器。
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
其他的
{
app.UseExceptionHandler(“/Home/Error”);
//有关在部署期间创建数据库的更多详细信息,请参阅http://go.microsoft.com/fwlink/?LinkID=615859
尝试
{
使用(var serviceScope=app.ApplicationServices.GetRequiredService()
.CreateScope())
{
serviceScope.ServiceProvider.GetService()
.Database.Migrate();
}
}
捕获{}
}
app.UseIISPlatformHandler(options=>options.AuthenticationDescriptions.Clear());
app.UseStaticFiles();
app.UseIdentity();
//要配置外部身份验证,请参阅http://go.microsoft.com/fwlink/?LinkID=532715
app.UseMvc(路由=>
{
routes.MapRoute(
名称:“默认”,
模板:“{controller=Home}/{action=Index}/{id?}”);
});
//使用示例数据种子数据库-管理员角色、管理员用户等
等待dbContextInitializer.InitializeDataAsync();
}
//应用程序的入口点。
publicstaticvoidmain(字符串[]args)=>WebApplication.Run(args);
}
更新

我已经为chrome安装了livereload插件,并按照vendettamit在下面的评论中的建议在gulp中配置了livereload。当我修改CSS/Less文件时,Chrome浏览器正在更新。由于浏览器链接不起作用,我仍然缺少web essentials设计和检查工具,但我希望这将在ASP.NET framework和/或visual studio的未来更新中有所改变

如果有人无意中发现同样的问题,我将为gulp编写脚本:

    /// <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']);
});
//
“严格使用”;
var gulp=需要(“gulp”),
rimraf=要求(“rimraf”),
concat=需要(“吞咽concat”),
cssmin=需要(“吞咽cssmin”),
uglify=需要(“吞咽uglify”),
减少=需要(“减少吞咽”),
livereload=需要(“吞下livereload”);
var project=require('./project.json');
变量路径={
webroot:“./wwwroot/”
};
path.js=path.webroot+“js/***.js”;
path.minJs=path.webroot+“js/***.min.js”;
path.css=path.webroot+“css/***.css”;
path.minCss=path.webroot+“css/***.min.css”;
path.concatJsDest=path.webroot+“js/site.min.js”;
path.concatCssDest=path.webroot+“css/site.min.css”;
任务(“clean:js”,函数(cb){
rimraf(path.webroot+“/js/site.min.js”,cb);
rimraf(path.webroot+“/js/site.js”,cb);
});
任务(“清理:css”,函数(cb){
里默