Skip to main content
Question

How to get acumatica Instance URL and HostName

  • 21 June 2024
  • 7 replies
  • 121 views

 

How to get this Acumatica URl in code Currently i use System.Web.HttpContext.Current.Request.Url.AbsoluteUri.ToString() But some time it is null. So it not solve my purpose to get URL. Also some time PX.Data.Update.PXInstanceHelper.HostName is null

7 replies

Userlevel 7
Badge +19

@hyadav08  Can you please try below code?

 

HttpContext.Current.Request.Url.Host  + HttpContext.Current.Request.ApplicationPath;

@Naveen Boga
HttpContext.Current is Null than how to access the Host Name and URL.
I have already mention this in Question that is null.
Please provide other option or why it is null

Userlevel 7
Badge +19

@hyadav08  I Just checked and it is working great for me and not sure why it is NOT working for you.

 

Have you checked in another instance? and where are you trying to access this URL and host name in the code?

@Naveen Boga 
I have Press Release Button from Purchase order and check the value in Acumatica graph or graph create by us and check the value in both the graph HttpContext.Current is Null 

Userlevel 5
Badge +2

@Naveen Boga 
It’s probably a matter of referencing HttpContext in a background thread (PXLongOperation) instead of the current thread: https://stackoverflow.com/a/78669334/7376238

Userlevel 7
Badge +19

@Hughes Beausejour - Thanks for sharing the details.

Hyadav08 is written the code in the RELEASE button which is already part of the LongRun Operation, hence which is why request is NULL. In this case, how can we get these details in the Release button?

Userlevel 7
Badge

Hi @hyadav08 were you able to find a solution? Thank you!

Reply