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

Announcements

No record found.

News and Announcements icon
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)
  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    Try URLUtility::getUrl().

  • Pete Alberts Profile Picture
    3,542 on at

    Thanks Nikolaos

    Unfortunately it also uses SessionContext.

  • Verified answer
    Pete Alberts Profile Picture
    3,542 on at

    I have found it though.

    System.Web.HttpContext::Current.Request

  • nmaenpaa Profile Picture
    101,166 Moderator on at

    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.

  • Pete Alberts Profile Picture
    3,542 on at

    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
  • Sukrut Parab Profile Picture
    71,735 Moderator on at

    Hi Pete ,

    Marked your response as verified as you have found solution.

  • Community Member Profile Picture
    on at

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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 616

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 460 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 331 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans