View Full Version : asp.net simple request help
10-10-2008, 11:26 AM
Its been a long time since I ever looked at asp or .net.
I need a script that when called recieves 2 parameters and checks the domain of the page that called it.
As a response it returns some html code.
Could somebody help me out on this? Maybe even a link to a good tutorial?
10-10-2008, 10:33 PM
What language were you wanting to write it in? If you're using ASP.NET, you can use either C# or VB.NET.
10-13-2008, 09:10 AM
Its .net I'm using and I'd prefer to take the c# route
10-13-2008, 05:49 PM
I'm not sure that I know of a good tutorial out there for this specific subject. Your best bet will probably be in reviewing the documentation at MSDN and googling around a little bit.
HttpRequest (http://msdn.microsoft.com/en-us/library/system.web.httprequest(VS.80).aspx) will be your bread and butter for detecting what's coming in via http, where it's coming from, and what's being sent through the request (ie: session data, cookies, query string parameters, etc).
Specifically, you'll want to have a look at the HttpRequest.UrlReferrer (http://msdn.microsoft.com/en-us/library/system.web.httprequest.urlreferrer(VS.80).aspx) property. This will give you the information about the domain that the request originated from.
In the example from your original post, I'd do something like:
protected void Page_Load(object sender, EventArgs e)
string url = Request.UrlReferrer.AbsolutePath;
else if (url.Contains("otherdomain.com"))
Another (more ideal) solution would be to not even worry about the domain that the request originated from. Rather than detecting the originating domain and programatically generating your HTML from C#, you could look for a parameter on the query string that you'd use to grab an XSLT file. The specific XSLT file would worry about generating the HTML from data stored in XML. Essentially, all you'd do in C# would be to return the result of the XSLT transformation through the http response.
10-14-2008, 09:18 AM
Thats great information to get me started.
vBulletin® v3.8.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.