How could I get the server name in Server method and Client method

Hi All,

I want to get the server name in my method to distinguish between production server and testing server .

So how do I get it?

Thanks.

  • Tenny, 

    The answer depends slightly on how your production and test servers are set up, but I would see if the aras.getDatabase() or aras.getServerUrl() functions work for you. The former returns the name of the database you're using, while the latter will get the url your Innovator instance is set up on. If you're using getServerUrl, you might need to do a little string manipulation to strip off the prefixes- certainly "http://" but most of my testing happens on localhost/[servername]- but it should have your server at the end.

    Skyler C.

  • Hi Skyler,

    thanks your information,I use getInnovator().getConnection().GetDatabaseName() to get the database name in server method,could you give an example to  getserverurl in server method,I use the  getInnovator().getConnection().getServerUrl(). it can't work .

    thanks

    Tenny 

  • You can use something simple like that:

    string baseUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + HttpContext.Current.Request.ApplicationPath.Replace("Server","");

  • To add onto this, you can also use the line below to get the URL of your instance from a client method:

    var baseUrl = aras.getInnovatorUrl();

    Chris