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

3

10

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.

Lumbering answered 10/7, 2016 at 8:26 Comment(1)
Same issue here. Can't get browserlink to work even after following numerous suggestionsAdigun
G
6

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

Goebbels answered 10/7, 2016 at 8:36 Comment(6)
Is your project an asp.net core v1.0 webapp? As per my original post i have added the same dependency in project.json and have enabled browser link via the UI you screenshot above. Still not working.Lumbering
Yes web, only .NET Core projects have a project.json file. Try to click "Refreshed Linked Browsers", in my case no connections showed up initially, but after refresh.Goebbels
I have updated my original post. The "Refresh Linked Browsers" option is disabled for me. My Startup.cs already has the app.UserBrowserLink() call and my project builds fine, so I don't have the issue you linked here. When you run the project are you doing "Start Debugging" or "Start without Debugging"... which option is supported by browser link, as I notice that the BrowserLink Dashboard has an option for "View in Browser" which launches without debugging... (still doesn't work for me)Lumbering
"Start Debugging" or "Start without Debugging", both options work with browser link. But some more questions: Do u have any VS extensions installed, I saw your screenshot, what is the VS2012 icon for?? Do you run the web app on localhost... ? To be honest, I've never seen a disabled browser link refresh button. Do you see the the browser link scripts being rendered in your browser?Goebbels
I'm using VS2015 Update 3. The extra menu options are due to the Web Essentials extension, which I am using the latest version of (3.0.230). This extension adds some features for Browser Link. I am running on localhost:port using IIS Express.Lumbering
Hm, difficult to say. I don't have them installed, but try to deactivate/unistall Web Essentials... and try it again... Perhaps Web Essentials has it's own log files, check them if available. What does the Eventviewer say?Goebbels
A
1

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.

Agranulocytosis answered 25/8, 2016 at 12:21 Comment(1)
Thank you for this. It resolved my issue. If you have VS2015u3, and the latest tooling, but browserlink is just refusing to work take a hard look at your installed SDKs. I had multiple previous versions installed. I removed all .NET Core SDKs, including the VS2015 tooling. Reinstalled latest 1.0.3 SDK, followed by the latest tooling, and my issue was resolved.Rieth
C
1

I was having the same problem with building a .NET Core MVC app from the empty template, but I figured out that the "Web Application" template works for me out of the box.

ASP.NET Core Templates Dialog: Choose Empty, Web API, or Web Application

So, I checked all of the configuration JSON files to see what the differences were.

Empty ProjectWeb Application Project: Extra config files are appsettings.json and bundleconfig.json

Starting from the bottom, web.config between the two are actually identical, so you don't have to add anything there.

In the Web App project, Startup.cs has the following code inside the Configure() method:

if (env.IsDevelopment())
{
    app.UseDeveloperExceptionPage();
    app.UseBrowserLink();
}

In project.json, you've already been told to put the following in the dependencies section:

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

bundleconfig.json just tells the app how to bundle and minify JavaScript, so that doesn't affect BrowserLink.

Now, this next one I don't get. appsettings.json doesn't exist in the empty project, and you were told to put an appsettings tag in your web.config. Since MS is trying to go away from the web.config, I figured I would find something about BrowserLink in that appsettings.json. Nope:

}
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information"
    }
  }
}

Okay, whatever, at this point I'll try anything. Copy the text, restart Visual Studio, run my project (make sure to navigate to a page that is not just static HTML) and...

Browser Link Works!

Any time you browse to a static HTML page, you'll lose Browser Link, but other than that, it works pretty well. My advice: now that you know how much of a headache it is to do this, never start from an empty project, ever again.

Chukchi answered 17/11, 2016 at 18:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.