When we were using standart .net platform we were able to include css and js files by action and controller name by a code like this;
string scriptSource = Url.Content(string.Format("~/js/page/{0}/{1}.js", controllerName, actionName));
if (System.IO.File.Exists(Server.MapPath(scriptSource)))
{
<script type="text/javascript" src="@scriptSource"></script>
}
We were putting these codes in Layout and It was working when you name js folder same as controller name and js file same as action name..
For a while ago I upgraded project to .Net Core(2.1) and made dependecy injection to BaseController to get Server.MapPath value, but I couldn't reach from _Layout view to the BaseController or codebehind to get Server.Mappath.. If any of you could succeeded this please let me know.