I'm trying to get javascript debugging working in Visual Studio 2017 Community Edition for javascript that is included inline in a .cshtml file. But I can't seem to find any way to get it working.
My simple test is a asp.net core web project targeting the full framework.
/Controllers/HomeController.cs
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
}
/views/Home/Index.cshtml
<html>
<head>
<script type="text/javascript">
function doWork() {
var num = 1;
alert('Hello. Number is ' + num)
}
</script>
</head>
<body>
<h1>JS Debugging test</h1>
<button type="button" onclick="doWork()">Do Work</button>
</body>
</html>
I set a break point on the javascript alert line like so:
I'm using VS2017 with it's default settings on Windows 10, so VS is configured to launch Microsoft Edge when running a web application. Then I hit F5
to run the solution with debugging. It runs fine but the breakpoint changes to show it won't be hit and displays the message below:
I've confirmed that the web project properties has define debug constant checked and define trace constant checked, as well as optimize code unchecked. I'm seriously puzzeled as to why I can't debug javascript included in a script tag on a razor page.
I have googled like crazy on this one to no avail and am starting to think that VS 2017 doesn't support js debugging of script on a razor page. I recently found someone else stating as much about VS2012 on here: The breakpoint will not currently be hit. No symbols have been loaded But I'm hoping VS2017 supports this debugging scenario.
So, how can I get VS 2017 to support debugging of javascript placed in a script tag in a .cshtml file, or is that just not possible?