Let’s Imagine the Following Example Scenario:
More specifically, the basic restrictions/challenges that we are going to impose in this example that restrict what solutions we can use are:
- We can apply code changes to two domains, but we cannot in any way change the web.config files or the IIS settings.
Deciding what Solution to Use
There are a number of ways that you could use to try to communicate cross domain with your ASP.NET code. You could call an ASP.NET web service via an AJAX request if your receiving server is properly set up. Likewise you could set up a JSONP call via JQuery to a file on your ASP.NET enabled Web server.
These options are all quite involved and can easily frustrate you with the code related security settings that need to be configured in order for the cross domain/cross server communication to work.
How Does it Work?
For starters you’ll need to write the ASP.NET object on your remote server:
- This will make sure that a .js response will be returned to your calling page.
- When the ASP.NET page is loaded remotely, in order for the page to render, the user will be authenticated using Windows Authentication on the remote server.
- This means that you can get the user’s ID in the standard way using: HttpContext.Current.User.Identity.Name;
An ASP.NET Web Page Written in C# Called MyScriptPageCSharp.aspx
The Same ASP.NET Web Page, but Written in VB.NET: Called MyScriptPageVB.aspx
Here is the same example as above, but written in VB.NET