web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Get current URL without SessionContext

(0) ShareShare
ReportReport
Posted on by 3,542

Hi folks

I want to get the current URL or http request. For reasons the current session is causing problems for me. So is there some code to get the current URL, without using SessionContext.Get_RequestURL()?

I am very far down the rabbit hole. Very far from the original issue. So I can expand, but there is no short way to do so. Meaning if there is no straight answer to the above, please ask for more info and then I will write you a 1000 word essay.

Thanks for your attention

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: Get current URL without SessionContext

    I am very far down the rabbit hole. Very far from the original issue.

  • Sukrut Parab Profile Picture
    71,699 Moderator on at
    RE: Get current URL without SessionContext

    Hi Pete ,

    Marked your response as verified as you have found solution.

  • Pete Alberts Profile Picture
    3,542 on at
    RE: Get current URL without SessionContext

    The context boils down like this:

    1. Integrating with LinkedIn
    2. Need to accept a token at redirect URL
    3. Created a service for this purpose
    4. Redirect call wasn't working.
    5. Installed postman to check if my service works
    6. Discovered that the token is passed through as a request parameter and not body
    7. A custom service method parameter maps to a http request body member
    8. So I need the current URL
    9. I looked at the SysClassRunner example (it takes your class name as a http request parameter)
    10. It threw errors in an inconsistent fashion
    11. After a lengthy investigation I found it is because sometimes there is no session (meaning null SessionContext). If I have a current session open the postman call works (but not as it should).
    12. So I looked into Sessions. Tried to create a session from code.
    13. I stopped and made this post. (I mean I only wanted to get a token and now I'm struggling with sessions.)
    14.  Came across the code I mentioned in my previous reply.
    15. Successsssssssss
  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Get current URL without SessionContext

    So, can you explain why the SessionContext is causing issues for you? As far as I understand, the URL of the request can only exist in context of a session.

  • Verified answer
    Pete Alberts Profile Picture
    3,542 on at
    RE: Get current URL without SessionContext

    I have found it though.

    System.Web.HttpContext::Current.Request

  • Pete Alberts Profile Picture
    3,542 on at
    RE: Get current URL without SessionContext

    Thanks Nikolaos

    Unfortunately it also uses SessionContext.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Get current URL without SessionContext

    Try URLUtility::getUrl().

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 846

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 810 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 797 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans