I found a .cshtml file with the following structure (please excuse any inaccuracies in my JavaScript jargon)
@model SomeViewModel
@{ Response.ContentType = "application/x-javascript"; }
$(function() {
// Code for handling Javascript events here
}
});
$(function ($) {
// Extensions for JQuery.DatePicker in Javascript go here
}
});
I suspect there is a bug that needs to be fixed in the second JS block, but I'm having trouble debugging it. I am using Chrome.
The situation is complicated by the presence of a MyDatepicker.js
file elsewhere in the solution with the same javascript code, and a MyDatepicker.min.js
which appears at runtime and can be debugged (to some extent).
Therefore:
- What happens to the JS code in the cshtml file - can I disregard it?
- How can I ensure that a non-minified version of the javascript is loaded?
- How do I determine where the minified version of the script originates from?
Following the advice provided below, I discovered the following class.
public class MyDatePickerController : Controller
{
// GET: /jquery.mydatepicker.js
[Minify]
[HttpGet]
public ActionResult Index()
{
MyDatePickerViewModel model = new MyDatePickerViewModel();
return View(model);
}
}
This seems to clarify how the javascript gets minified.
Since there is a MyDatePicker.js file alongside the code in the .cshtml file, I am still uncertain about which version of the javascript is being loaded. I will edit one of them, remove the minify
, and observe which one is loaded.
Now that I have identified why the script was getting minified, I have confirmed that the executed javascript was from the razor file (.cshtml
)