Skip to main content
added 2 characters in body
Source Link
Robert Lindgren
  • 24.5k
  • 12
  • 55
  • 79

I have deployed a custom ribbon button and when a user clicks it, I open a custom application page - I have deployed the page to _layouts mapped folder. To open the page (with JavaScript), so far I'm providing an absolute URL which looks like this:

targetUrl = 'http://srvr/sites/Site1/_layouts/MyProject/AppPage.aspx'; 

where http://srvr/sites/Site1 is the "Site URL" property of my Visual Studio project (deployed as a farm solution).

My question is: how do I determine the URL of AppPage.aspx independently of the environment, i.e. in a relative manner? E.g. if I deploy to a farm where "Site1" doesn't exist, in what way should I construct the target URL? I assume what I'm trying to do is to deploy the application page in a way that won't rely on the existence of 'Site1' site collection. Would deploying to _admin mapped folder instead of _layouts make sense (I want the app page to be viewable by normal users, not just admins)?

(UPDATE) Here's the complete JS code that I use to open the application page (as a dialog):

function OpenMyAppPage() { var options = SP.UI.$create_DialogOptions(); options.url = 'http://srvr/sites/Site1/_layouts/MyProject/AppPage.aspx'; options.url += "?Location=" + location.href; options.width = 400; options.height = 200; options.allowClose = false; options.allowMaximize = false; options.title = 'Example'; SP.UI.ModalDialog.showModalDialog(options); } 

Note: simply changing the url to '/_layouts/MyProject/AppPage.aspx''/_layouts/MyProject/AppPage.aspx' gives me error 404.

I have deployed a custom ribbon button and when a user clicks it, I open a custom application page - I have deployed the page to _layouts mapped folder. To open the page (with JavaScript), so far I'm providing an absolute URL which looks like this:

targetUrl = 'http://srvr/sites/Site1/_layouts/MyProject/AppPage.aspx'; 

where http://srvr/sites/Site1 is the "Site URL" property of my Visual Studio project (deployed as a farm solution).

My question is: how do I determine the URL of AppPage.aspx independently of the environment, i.e. in a relative manner? E.g. if I deploy to a farm where "Site1" doesn't exist, in what way should I construct the target URL? I assume what I'm trying to do is to deploy the application page in a way that won't rely on the existence of 'Site1' site collection. Would deploying to _admin mapped folder instead of _layouts make sense (I want the app page to be viewable by normal users, not just admins)?

(UPDATE) Here's the complete JS code that I use to open the application page (as a dialog):

function OpenMyAppPage() { var options = SP.UI.$create_DialogOptions(); options.url = 'http://srvr/sites/Site1/_layouts/MyProject/AppPage.aspx'; options.url += "?Location=" + location.href; options.width = 400; options.height = 200; options.allowClose = false; options.allowMaximize = false; options.title = 'Example'; SP.UI.ModalDialog.showModalDialog(options); } 

Note: simply changing the url to '/_layouts/MyProject/AppPage.aspx' gives me error 404.

I have deployed a custom ribbon button and when a user clicks it, I open a custom application page - I have deployed the page to _layouts mapped folder. To open the page (with JavaScript), so far I'm providing an absolute URL which looks like this:

targetUrl = 'http://srvr/sites/Site1/_layouts/MyProject/AppPage.aspx'; 

where http://srvr/sites/Site1 is the "Site URL" property of my Visual Studio project (deployed as a farm solution).

My question is: how do I determine the URL of AppPage.aspx independently of the environment, i.e. in a relative manner? E.g. if I deploy to a farm where "Site1" doesn't exist, in what way should I construct the target URL? I assume what I'm trying to do is to deploy the application page in a way that won't rely on the existence of 'Site1' site collection. Would deploying to _admin mapped folder instead of _layouts make sense (I want the app page to be viewable by normal users, not just admins)?

(UPDATE) Here's the complete JS code that I use to open the application page (as a dialog):

function OpenMyAppPage() { var options = SP.UI.$create_DialogOptions(); options.url = 'http://srvr/sites/Site1/_layouts/MyProject/AppPage.aspx'; options.url += "?Location=" + location.href; options.width = 400; options.height = 200; options.allowClose = false; options.allowMaximize = false; options.title = 'Example'; SP.UI.ModalDialog.showModalDialog(options); } 

Note: simply changing the url to '/_layouts/MyProject/AppPage.aspx' gives me error 404.

added 653 characters in body
Source Link
w128
  • 652
  • 1
  • 9
  • 33

I have deployed a custom ribbon button and when a user clicks it, I open a custom application page - I have deployed the page to _layouts mapped folder. To open the page (with JavaScript), so far I'm providing an absolute URL which looks like this:

targetUrl = 'http://srvr/sites/Site1/_layouts/MyProject/AppPage.aspx'; 

where http://srvr/sites/Site1 is the "Site URL" property of my Visual Studio project (deployed as a farm solution).

My question is: how do I determine the URL of AppPage.aspx independently of the environment, i.e. in a relative manner? E.g. if I deploy to a farm where "Site1" doesn't exist, in what way should I construct the target URL? I assume what I'm trying to do is to deploy the application page in a way that won't rely on the existence of 'Site1' site collection. Would deploying to _admin mapped folder instead of _layouts make sense (I want the app page to be viewable by normal users, not just admins)?

(UPDATE) Here's the complete JS code that I use to open the application page (as a dialog):

function OpenMyAppPage() { var options = SP.UI.$create_DialogOptions(); options.url = 'http://srvr/sites/Site1/_layouts/MyProject/AppPage.aspx'; options.url += "?Location=" + location.href; options.width = 400; options.height = 200; options.allowClose = false; options.allowMaximize = false; options.title = 'Example'; SP.UI.ModalDialog.showModalDialog(options); } 

Note: simply changing the url to '/_layouts/MyProject/AppPage.aspx' gives me error 404.

I have deployed a custom ribbon button and when a user clicks it, I open a custom application page - I have deployed the page to _layouts mapped folder. To open the page (with JavaScript), so far I'm providing an absolute URL which looks like this:

targetUrl = 'http://srvr/sites/Site1/_layouts/MyProject/AppPage.aspx'; 

where http://srvr/sites/Site1 is the "Site URL" property of my Visual Studio project (deployed as a farm solution).

My question is: how do I determine the URL of AppPage.aspx independently of the environment, i.e. in a relative manner? E.g. if I deploy to a farm where "Site1" doesn't exist, in what way should I construct the target URL? I assume what I'm trying to do is to deploy the application page in a way that won't rely on the existence of 'Site1' site collection. Would deploying to _admin mapped folder instead of _layouts make sense (I want the app page to be viewable by normal users, not just admins)?

I have deployed a custom ribbon button and when a user clicks it, I open a custom application page - I have deployed the page to _layouts mapped folder. To open the page (with JavaScript), so far I'm providing an absolute URL which looks like this:

targetUrl = 'http://srvr/sites/Site1/_layouts/MyProject/AppPage.aspx'; 

where http://srvr/sites/Site1 is the "Site URL" property of my Visual Studio project (deployed as a farm solution).

My question is: how do I determine the URL of AppPage.aspx independently of the environment, i.e. in a relative manner? E.g. if I deploy to a farm where "Site1" doesn't exist, in what way should I construct the target URL? I assume what I'm trying to do is to deploy the application page in a way that won't rely on the existence of 'Site1' site collection. Would deploying to _admin mapped folder instead of _layouts make sense (I want the app page to be viewable by normal users, not just admins)?

(UPDATE) Here's the complete JS code that I use to open the application page (as a dialog):

function OpenMyAppPage() { var options = SP.UI.$create_DialogOptions(); options.url = 'http://srvr/sites/Site1/_layouts/MyProject/AppPage.aspx'; options.url += "?Location=" + location.href; options.width = 400; options.height = 200; options.allowClose = false; options.allowMaximize = false; options.title = 'Example'; SP.UI.ModalDialog.showModalDialog(options); } 

Note: simply changing the url to '/_layouts/MyProject/AppPage.aspx' gives me error 404.

Source Link
w128
  • 652
  • 1
  • 9
  • 33

How to determine custom application page URL independently of the environment/farm?

I have deployed a custom ribbon button and when a user clicks it, I open a custom application page - I have deployed the page to _layouts mapped folder. To open the page (with JavaScript), so far I'm providing an absolute URL which looks like this:

targetUrl = 'http://srvr/sites/Site1/_layouts/MyProject/AppPage.aspx'; 

where http://srvr/sites/Site1 is the "Site URL" property of my Visual Studio project (deployed as a farm solution).

My question is: how do I determine the URL of AppPage.aspx independently of the environment, i.e. in a relative manner? E.g. if I deploy to a farm where "Site1" doesn't exist, in what way should I construct the target URL? I assume what I'm trying to do is to deploy the application page in a way that won't rely on the existence of 'Site1' site collection. Would deploying to _admin mapped folder instead of _layouts make sense (I want the app page to be viewable by normal users, not just admins)?