How to get full host name + port number in Application_Start of Global.aspx?

When your web application starts, there is no HTTP request being handled. You may want to handle define the Application_BeginRequest(Object Sender, EventArgs e) method in which the the Request context is available. Edit: Here is a code sample inspired by the Mike Volodarsky’s blog that Michael Shimmins linked to: void Application_BeginRequest(Object source, EventArgs e) { … Read more

Java SSL: how to disable hostname verification

It should be possible to create custom java agent that overrides default HostnameVerifier: import javax.net.ssl.*; import java.lang.instrument.Instrumentation; public class LenientHostnameVerifierAgent { public static void premain(String args, Instrumentation inst) { HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { public boolean verify(String s, SSLSession sslSession) { return true; } }); } } Then just add -javaagent:LenientHostnameVerifierAgent.jar to program’s java startup arguments.

How to extract the hostname portion of a URL in JavaScript

suppose that you have a page with this address: http://sub.domain.com/virtualPath/page.htm. use the following in page code to achive those results: window.location.host : you’ll get sub.domain.com:8080 or sub.domain.com:80 window.location.hostname : you’ll get sub.domain.com window.location.protocol : you’ll get http: window.location.port : you’ll get 8080 or 80 window.location.pathname : you’ll get /virtualPath window.location.origin : you’ll get http://sub.domain.com ***** … Read more