By using SPAlternateURL object, you can get the URL or SharePoint 2010 Web Application since the alternate access mappings are associated with a Web Application. Sample code is provided below:
In order to call these functions, you need to pass either SPWebApplication, SPSite or SPWeb object and specify the SPUrlZone enumeration which has the following originating zone of a request:
- Default - Specifies the default zone used for requests unless another zone is specified.
- Intranet - Specifies an intranet zone.
- Internet - Specifies an Internet zone.
- Custom - Specifies a custom zone.
- Extranet - Specifies an extranet zone.