Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to to create a link on one web application to another web application using C#.

Code is running on:

http://portal

I want to create a link to http://my.

The farm is also available on a FQDN domain:

http://portal.company.local

http://my.company.local

So what is the best code or control to create a link to the other AAM web application? At the moment I'm doing something like this:

<%= SPWebApplication.Lookup(
        new Uri("http://my")).AlternateUrls.
            GetResponseUrl(SPAlternateUrl.Lookup(
                new Uri(SPContext.Current.Web.Url)).UrlZone).Uri %>

It works, but I'm not sure if this is the right and performant way.

Any ideas?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Looks good to me! I'm pretty sure you can only look up AAM URLs via SPWebApplication so this is the way to do it.

If you are concerned about performance, measure the difference between when you have this on the page and when you remove it. ASP.NET Tracing is one option that can help.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.