I’ve got a web app that I deploy to several applications like so-
https://customerinternaldomain.com/thewebapp
There are a lot links that pop open windows. In the past I was using the following to determine the url of the window to pop.
string appPath = this.Request.ApplicationPath;
if ( !appPath.EndsWith ( "/" ) )
appPath += "/";
string sURL = this.Request.Url.Scheme + "://" + this.Request.Url.Authority
+ appPath
Then I just append on the path to the window page that I want to open like so
appPath += "somefolder/window.aspx"
One of our installations just moved to a non standard port, something like 20055.
So I’ve fooled around with coming up with a clean full proof way to make sure that the port is inserted in the path, but since the webapp is mapped to https://internaldomain.com/thewebapp instead of just https://internaldomain.com/ I’m not seeing a clean way using Request server variables to do this. Sure I can hack and slash with splits or something, or store the base web path in a config file that gets read. Just wondering if anyone had a clean way of doing this. Assuming something obvious that I’m just missing, so I figured I’d put the best and brightest on it.
Thanks for any help you provide, I know time is valuable. I appreciate it.
I don’t have access to an ASP server or Visual Studio right now to get the details, but I know you can get the domain name, and the URL path from it, from the Request.Url object. Quick search tells me it’s Request.Url.Host to get the internaldomain.com part.
So, you would just have to append the port to this, and piece it all together.
So, it’d be something like
scheme + “://” + host + “:” + port “/” + currentPath + “/” + appPath
As I said, can’t check the specifics right now, but I know the Request object will let you access all these parts. The port you may have to store somewhere, if you’re going from one port to another.