Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browser Link with ASP.NET Core v1.0 in Visual Studio 2015 Update 3

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. Is Browser Link supported for ASP.NET Core v1.0 projects?

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.

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

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. For an ASP.NET Core v1.0 project, what else do I need to do to get Browser Link working?

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.

enter image description here

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

like image 296
chumtoadafuq Avatar asked Jul 10 '16 08:07

chumtoadafuq


People also ask

What is ASP net 3.0 web application?

ASP.NET is an open-source, server-side web-application framework designed for web development to produce dynamic web pages. It was developed by Microsoft to allow programmers to build dynamic web sites, applications and services.


2 Answers

I am using VS2015 Update 3 too.

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

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

  app.UseBrowserLink();

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

Set appSetting “vs:EnableBrowserLink” to “true

enter image description here

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>

Try to click

"Refreshed Linked Browsers",

enter image description here

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:

enter image description here

In my project.json I have the following setting:

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

and Browserlink has to be enabled:

enter image description here

You can see if it's loaded in the browsers network tab: enter image description here

like image 121
Legends Avatar answered Oct 09 '22 20:10

Legends


I still had old versions of the .net core installed as well as the SDK. I removed these (from Control Panel), and reinstalled the Tooling Preview 2 from: https://www.microsoft.com/net/core#windows

And hey-presto BrowserLink starts working.

like image 30
Tod Avatar answered Oct 09 '22 20:10

Tod