To get username or login name using SSOM is very simple
string strUserName = SPContext.Current.Web.CurrentUser.LoginName;
To get username from CSOM
function getCurrentUser() {
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var currentUser = web.get_currentUser();
context.load(currentUser);
context.executeQueryAsync(onSuccessMethod, onRequestFail);
}
You can use this query string to pass username to another URL.Make sure it is encrypted before passing inin url