How to get the root of an application in ASP.NET
Author: Veeresh Rudrappa. Date: Feb 16, 2013
Here is an easy way to get your application path. It is very helpful to declare a String variable at the top of your cshtml or aspx page and use it to access any files with in your project.
String applicationRoot = ( Request.ApplicationPath == "/" ) ? String.Empty : Request.ApplicationPath;
Request.ApplicationPath will get us the ASP.NET application's virtual application root path on the server. Use the variable "applicationRoot" within <%= %> tag in aspx or with @ tag in razor pages.
For Example:< script src="@applicationRoot/Scripts/jquery-1.5.1.min.js" type="text/javascript"> < /script>