Server variables and redirect

I know nothing about but i have problem which i think i can solve using it.

I have an ISAPI dll written using Intraweb (if you have not heard of it – don’t worry).

On my web site I have an isapi filter that prompts the user to login (via gmail or facebook), and then the users details are passed on to the web application as a number of server variables.
The web application, in my case an Intraweb isapi dll, does not seem to be able to read these variables… however I have some code that does.  So I know I can be done.

So I would like to write some code that looks for the variables, adds them to the request, and then does a redirect (or transfer) to my isapi.dll

This must be possible?

Sort of:

Get the server variable “USER_ID”

Add it to the current request as a query field, or content field

Redirect to my isapi dll

Can this be done? And how?

Who is Participating?
Miguel OzConnect With a Mentor Software EngineerCommented:
It is possible, but why are you using the same request url? I think you should use a page as your point of entry and then redirect  to your Intraweb app. (If so just replace
Request.RawUrl  with  the new url)
You need to use the servervariables collection  in the Page_load event of your as follows:
protected void Page_Load(object sender, EventArgs e)
   if (!Request.RawUrl.Contains("userId=")) //avoids adding the same var when page is called the second time
            string userId = Request.ServerVariables["USER_ID"] + "3";
            string newUrl = Request.RawUrl + "?userId=" + userId; // if url has query parameters already use "&userId=" + userId

Open in new window

soozhAuthor Commented:
Thanks for the response.  

The example of code i have has "runat server" and some code that extracts the USER_ID.  

As the new page is on the same server perhaps i should use Transfer?
soozhAuthor Commented:
I have tested your solution and passed the data as a Query fields.  This worked and i could read the fields in my Intraweb app.

However i would rather pass the data as content fields.

Any ideas how i would do that?
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Miguel OzSoftware EngineerCommented:
Glad I solved your original question.
Regarding post-question I am not sure what you meant by content fields. Please provide example.
soozhAuthor Commented:
hmm... now you want me to be an expert!

In intraweb there are Query Fields (which are part of the url) and Content Fields (which are not!).

I started to play around with the following code:

  // Get the login variables
  string username = Request.ServerVariables["IDP_USERNAME"] ;
  string email = Request.ServerVariables["IDP_EMAIL"] ;
  string uid = Request.ServerVariables["IDP_UID"] ;

  // Create the new request
  var request = WebRequest.Create("http://79.XXX.XXX.XX/PharosPortal/PharosPortal.dll/$/Start/");
  request.Method = "POST";
  request.ContentType = "application/x-www-form-urlencoded";
  using (var writer = new StreamWriter(request.GetRequestStream()))


Open in new window

I think this creates what i call content fields.  But when i run it i get an error complaining about WebRequest.

Compiler Error Message: CS0103: The name 'WebRequest' does not exist in the current context

Open in new window

from which i can tell that i need to include something - but what?
Miguel OzSoftware EngineerCommented:
Your post question requires knowledge of Intraweb based on your explanation and the Delphi compiler error message shown above, You should ask your post question in the Delphi area. I do not have experience with Delphi Intraweb so I can not comment whether your last comment's  code works or not.

Note: The only reason I answer your original question: " I have an ISAPI dll written using Intraweb (if you have not heard of it – don’t worry)."
soozhAuthor Commented:
This is did not 100% solve my problem but gave me some help in finding a solution.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.