Skip to main content
Question

How to get acumatica Instance URL and HostName


Forum|alt.badge.img

 

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

Naveen Boga
Captain II
Forum|alt.badge.img+19

@hyadav08  Can you please try below code?

 

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


Forum|alt.badge.img
  • Jr Varsity II
  • June 24, 2024

@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


Naveen Boga
Captain II
Forum|alt.badge.img+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?


Forum|alt.badge.img
  • Jr Varsity II
  • June 24, 2024

@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 


Hughes Beausejour
Acumatica Employee
Forum|alt.badge.img+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


Naveen Boga
Captain II
Forum|alt.badge.img+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?


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • July 31, 2024

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings