[SalesForce] How to open VF page in lightning Experience using URL link

Is there a way to open VF page in lightning experience using URL link?. I know we can use sforce.one.navigateToURL but in our case it would not work because The URL link is outside the salesforce.

Use case

  • We are sending an vf page link in the email some thing like <a href="https://na16.visual.force.com/apex/myTask"> Click Here</a>. this is working fine with classic but we are facing the issue if user is in lightning experience.

Issue

  • If user is in lightning experience then this URL link is not working as expected. It's open the VF page but without one.app container.

I have attached the screen short of both classic and lightning experience output.

If user is in classic then URL Link open below screen

enter image description here

If user is in lightning experience then URL Link open below screen

enter image description here

Expected output in lightning experience

enter image description here

Is there any way to get expected output?

Best Answer

I would recommend that you add conditional code at the top of your page that determines what environment the User is currently in, then either displays the page using the Lightning experience where it puts the page in a Lightning I-Frame or if the user is in Classic mode, directly displays it without the I-frame. See Sharing Visualforce Pages Between Classic and Lightning Experience which contains the code for how to do this.