Here is the trick I use:
A SharePoint user is actually based on network user (active directory).
When a user is connecting to SharePoint, it connects based on 'Integrated
Windows Authentication'.
You set up your custom web application to run based on same kind of
authentication (you do the settings from Control Panel -> Admin Tools ->
IIS admin); when the page Viewer web part try to open and show on
SharePoint your application page it will be asked for windows credential
for authentication, your custom web application will be 'hit' with the
same credentials as SharePoint page. At the start page of your
application (maybe at page_load) just use System.Environment.UserName to
retrieve the user name.