Base namespace, base URL, and links to other web sites
Starting with PageMethods 1.6, you can use the following features:
- Base namespace. Previously, the methods generated by PageMethods
were placed in the MyPageMethods namespace. It is now possible to
exchange this namespace with any of your liking.
- Base URL. With the previous versions, the URLs generated for every
page methods were relative to the referencing page. They were starting with ~/
and resolved automatically if used in the NavigateUrl property. It was
possible to make the URLs absolute - to the application - by using
PageMethodsEngine.ResolveUrl() on them.
It is now possible to specify a base URL to serve as the root for the
generated URLs.
If you use Visual Studio 2005 Web Applications - the default model for Visual
Studio 2003 - you can import PageList.xml files from other sites to be able to
reference them. Support for BaseUrl is also provided for Visual Studio 2005
Web Sites.
These features are supported by PageMethods for VS 2003 and 2005.
Used together, these two features provide a complete solution to reference at
the same time the current web site and remote web sites.
1) Base namespace
To specify the base namespace of your choice, you have two options:
- In a Web Application or Visual Studio 2003, change the "Custom Tool
Namespace" property of the PageList.xml file to any namespace of your
choice.

- If you use Web Sites (VS 2005's default mode) or even Web Applications,
you can edit the PageList.xml file and change the baseNamespace
attribute in Pages/Settings to any namespace of your choice.

Once you have done that, you don't reference your page methods through the
MyPageMethods namespace anymore, but through your own namespace

Please note that you should avoid using the same namespace as the web project
to avoid name conflicts.
2) Base URL
To specify the base URL to use, you have three options:
- In a Web Application or Visual Studio 2003, append the base URL to the
"Custom Tool Namespace" property of the PageList.xml file. The
separator is the vertical bar, which gives something like:
"MyPageMethods|http://mysite.com".

- If you use Web Sites (VS 2005's default mode) or even Web Applications,
you can edit the PageList.xml file and set the baseUrl attribute
in Pages/Settings.

- At runtime, you can change MyPageMethods.PageMethodsSettings.BaseUrl.
The default value comes from the "Custom Tool Namespace" property or
from the XML file.
Changing the base URL at runtime is useful typically when you want to use a
value contained in a configuration file.

If we don't specify a base URL for our page methods, the URL for
MyPageMethods.Customer.Display(12) results in something like
"~/customer/12.aspx".
If we use "http://mysite.com" as the base URL for our page methods, the URL
becomes "http://mysite.com/customer/12.aspx".
3) Referencing other web sites
Now that we have seen how to specify a base namespace and a base URL, we are
able to "import" web sites in our projects to create links to them.
All we have to do is:
- Integrate an external PageList.xml file in our project. The name of the
file needs to be changed because we may have our own PageList.xml file in the
project. Let's name it Site2PageList.xml, for example.
- Specify a base namespace for these imported page methods. Let's use Site2
for example.
- Specify a base URL. Something like "http://site2.com/myapp" probably.
Once this is done, we are all set! We can now reference page methods from our
site or from the external site.

Referencing web sites this way provides the same benefits that you get when
you reference the pages of your site: code completion, typed parameters, named
methods, in place documentation, etc.
Of course, you can import as many web sites as you want.