Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Best way to programmatically get url with dynamic port?
efess
#1 Posted : Friday, January 25, 2013 12:52:46 PM(UTC)
Groups: Member
Joined: 1/25/2013(UTC)
Posts: 3

Thanks: 2 times
I have a shortcut on my desktop which uses GotoApplication.aspx with the AppId of a web application to launch the page with the correct Dynamic Port. I'm trying to launch this application from within another application, and I need the redirect URL. I've looked at the UWS.Configuration API and couldn't find any way to do this.

How should this be accomplished? Call the GotoApplication.aspx in my app?
efess
#2 Posted : Friday, January 25, 2013 1:17:08 PM(UTC)
Groups: Member
Joined: 1/25/2013(UTC)
Posts: 3

Thanks: 2 times
I just realized that UWS.Configuration.WebAppConfigEntry inherits from ListenEndpoint, so I was able to use the GetBrowserUrls() function..

Is this the recommended method?

Thanks!
Ultidev Team
#3 Posted : Friday, January 25, 2013 2:38:53 PM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Hi!

Yes, ListenEndpoint.GetBrowserUrls(string wildcardReplacement) is the most likely to help method.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
1 user thanked Ultidev Team for this useful post.
efess on 1/28/2013(UTC)
Ultidev Team
#4 Posted : Friday, January 25, 2013 2:49:51 PM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Hi!

You may also consider using following not-yet-document method of the Metabase class:

Code:

/// (summary)
/// Generates port-agnostic link to an application via UWS Redirector.
/// (/summary)
/// (param name="appID")(/param)
/// (param name="host")
/// Optional. Host name or IP address to be used in the URL pointing to the UWS Recirector application. 
/// If null, default host will be used. If set to "*IOS*", host will be in the format of "machinename.local" or "machinename", 
/// depending on whether host machine is a member of a domain.
/// (/param)
/// (param name="optionalPathAndQueryString")Optional. A part to be appended to the redirection URL, 
/// in case start page is different from web app's default document.(/param)
/// (param name="portOrder")Optional. Lists port number preference order. 
/// Should be used when multiple non-80 and non-443 is used as listen addresses.(/param)
/// (returns)(/returns)
public static string CreateAppRedirectLink(Guid appID, string host = null, string optionalPathAndQueryString = null, params ushort[] portOrder)
{
    const string autoIOShost = "*IOS*";
    if (string.IsNullOrEmpty(host) || host == autoIOShost)
        host = GetDefaultHost(forIOS: host == autoIOShost);

    WebAppConfigEntry uwsRedirector = Metabase.FindApplication(AppPoolRegistrationHelper.LegacyCassiniExplorerAppID);
    string[] urls = uwsRedirector.GetBrowseUrls(host);

    StringBuilder url = new StringBuilder();
    url.Append(urls[0]);
    url.AppendFormat("GoToApplication.aspx/{0}", appID.ToString().ToUpper());

    if (portOrder != null)
    {
        foreach (ushort port in portOrder)
            url.AppendFormat(",{0}", port);
    }
    url.Append("/");

    if (!string.IsNullOrEmpty(optionalPathAndQueryString))
        url.Append(optionalPathAndQueryString.TrimStart('/'));

    return url.ToString();
}


Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
1 user thanked Ultidev Team for this useful post.
efess on 1/28/2013(UTC)
efess
#5 Posted : Friday, January 25, 2013 3:38:03 PM(UTC)
Groups: Member
Joined: 1/25/2013(UTC)
Posts: 3

Thanks: 2 times
Thanks guys, great product btw!
Ultidev Team
#6 Posted : Saturday, January 26, 2013 3:26:33 PM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Thank you! We're happy to hear our little web server helps someone.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Rss Feed  Atom Feed
Users browsing this topic
Guest (3)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.