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

情到浓时终转凉″ 提交于 2019-12-03 12:15:22

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

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",

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:

In my project.json I have the following setting:

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

and Browserlink has to be enabled:

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

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.

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.

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

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...

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!