try to combine (did not test, so there might be oversight)Request.ServerVariables["SERVER_NAME"] and Request.ServerVariables["SCRIPT_NAME"] or Request.ServerVariables["URL"]
Application_Start runs only once when a request is made, it does not run on its own. After that, unless you restart the server or modify global.asax, it will not run again
HTTP://CSDN.NET/AA
and
Request.ServerVariables["SCRIPT_NAME"] or Request.ServerVariables["URL"]