Visual Studio 2015 Update 3中具有ASP.NET Core v1.0的浏览器链接 [英] Browser Link with ASP.NET Core v1.0 in Visual Studio 2015 Update 3

查看:119
本文介绍了Visual Studio 2015 Update 3中具有ASP.NET Core v1.0的浏览器链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio 2015 Update 3,并希望在我的ASP.NET Core v1.0 WebApp项目中使用浏览器链接功能...但是我无法使浏览器链接正常工作.

I am using Visual Studio 2015 Update 3 and wanting to use the Browser Link feature with my ASP.NET Core v1.0 WebApp project... but I can't get Browser Link to work.

  1. ASP.NET Core v1.0项目是否支持浏览器链接?

关于在ASP.NET Core中使用Browser Link方面,我找不到很多东西.

I can't find much out there with regards to using Browser Link with ASP.NET Core.

我的项目构建正常,但是在同时运行或不运行调试的情况下,浏览器链接仪表板始终显示为无当前连接".

My project builds OK, but the Browser Link dashboard always shows as "No current connections" when running both with or without debug.

在我的project.json中,我正在导入Browser Link依赖项;

In my project.json i'm importing the Browser Link dependancy;

{
  "dependencies": {
    "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.EntityFrameworkCore": "1.0.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "web.config",
      "Views",
      "appsettings.json"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

我的web.config;

My web.config;

<handlers>
  <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    <add name="Browser Link for HTML" path="*.html" verb="*"
         type="System.Web.StaticFileHandler, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
         resourceType="File" preCondition="integratedMode" />
</handlers>

  1. 对于ASP.NET Core v1.0项目,我还需要做些什么才能使Browser Link正常工作?


更新1

我已经在我的web.config的根元素中添加了以下内容;


Update 1

I have added the following to the root element of my web.config;

<appSettings>
  <add key="vs:EnableBrowserLink" value="true"/>
</appSettings>
<system.web>
  <compilation debug="true"></compilation>
</system.web>

刷新链接的浏览器"选项仍对我禁用.

The "Refresh Linked Browsers" option is still disabled for me.

但仍无法通过浏览器链接启动并在浏览器链接仪表板中查看连接.

But still not working to launch with Browser Link and see the connection in the Browser Link Dashboard.

推荐答案

我也在使用VS2015 Update 3.

I am using VS2015 Update 3 too.

当然,ASP.NET Core项目也支持浏览器链接.

Browserlink is also supported for ASP.NET Core projects of course.

将以下代码添加到您的Startup.cs->配置方法中:

Add the following code to your Startup.cs -> Configure method:

  app.UseBrowserLink();

但是,如果您使用-> .NET Core 1.0- VS 2015 Tooling RC ,则

But if you use --> .NET Core 1.0 - VS 2015 Tooling RC then this could be your issue.

将app设置为"vs:EnableBrowserLink"设置为" true "

Set appSetting "vs:EnableBrowserLink" to "true"

在您的web.config文件中将编译调试设置为 true . 当debug为false时,将禁用Browserlink!

Set compilation debug to true in your web.config file. Browserlink will be disabled when debug is false!

<system.web>
  <compilation debug="true"></compilation>
</system.web>

尝试单击

刷新的链接浏览器",

"Refreshed Linked Browsers",

在我的情况下,最初没有建立任何连接,但是在刷新之后! 之后,当您将鼠标悬停在刷新图标上时,将显示一个工具提示,显示已连接的浏览器,例如:

in my case no connections showed up initially, but after refresh! After that when you hover over the refresh icon, a tooltip showing the connected browsers is displayed, like this for example:

在我的project.json中,我具有以下设置:

In my project.json I have the following setting:

 "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",

并且必须启用Browserlink:

and Browserlink has to be enabled:

您可以在浏览器的网络"标签中查看它是否已加载:

You can see if it's loaded in the browsers network tab:

这篇关于Visual Studio 2015 Update 3中具有ASP.NET Core v1.0的浏览器链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆