You could try the following code:
if (!SecurityManager.IsGranted(new RegistryPermission(PermissionState.Unrestricted)))
{
//do something.... not at full trust
}
if (!SecurityManager.IsGranted(new DnsPermission(PermissionState.Unrestricted)))
{
//do something.... not at full trust
}
I got this from the following link:
http://www.netomatix.com/development/webcaspermissions.aspx
here's links for the Security Manager and Registry Permission classes in MSDN:
http://msdn.microsoft.com/en-us/library/system.security.securitymanager.isgranted.aspx
http://msdn.microsoft.com/en-us/library/system.security.permissions.registrypermission.aspx
You will need to add a reference to System.Security and add a couple of using statements for System.Security and System.Security.Permissions.
EDIT:
Added after Nick's Comment:
You could test directly for the asp.net security level:
if (SecurityManager.IsGranted( new AspNetHostingPermission(AspNetHostingPermissionLevel.Medium)))
{Response.Write("Medium Trust level");}