locked
Add new Server Variable with HttpHandler RRS feed

  • Question

  • User-881571857 posted

     Hello,

     I was just wondering of this was possible with an HTTP Handler.

     I want to create a custom Server Variable at run time.  I wanted to share this Server Variable as a Single Sign-On to another application.

    For example, I need to send HTTP_FIRSTNAME to this other application on the same server.  Where the application will see Request.ServerVariables("HTTP_FIRSTNAME")

    as a test I have tried the following (does not work)

     
     

    1    Imports Microsoft.VisualBasic
    2    Imports System.Web
    3    
    4    Public Class HeaderHandler
    5        Implements IHttpHandler
    6    
    7        Public ReadOnly Property IsReusable() As Boolean Implements System.Web.IHttpHandler.IsReusable
    8            Get
    9                Return False
    10           End Get
    11       End Property
    12   
    13       Public Sub ProcessRequest(ByVal context As System.Web.HttpContext) Implements System.Web.IHttpHandler.ProcessRequest
    14   
    15           context.Request.Headers.Add("HTTP_FIRSTNAME", "THE FIRST NAME")
    16           context.Request.ServerVariables.Add("HTTP_LASTNAME", "THE LAST NAME")
    17   
    18   
    19       End Sub
    20   
    21   End Class 
    
     

     
     Is this only possible with an ISAPI filter?

    I cannot send this data in session or querystring, it must be send like this (requirement of the target application)

    I will be using the ASP.net Membership with Active Directory for my single sign-on application.

    Any help would greatly be appreciated, even if the answer is to use an ISAPI filter to do this, at least I will know that.

    Thanks,

     
    Dan 


     


     

    Friday, June 8, 2007 4:25 PM

Answers

  • User-225114762 posted

    I think you should try the reverse proxy option. There's a really simple skeleton available here: http://www.codeproject.com/aspnet/HTTPReverseProxy.asp . You should be able to use that for a proof of concept. If the target application renders HTML with absolute URLs you may need to do some rewriting of the outgoing HTML, otherwise you won't get subsequent requests to your proxy.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, June 10, 2007 4:09 AM

All replies

  • User-225114762 posted

    It's rather unclear what you mean with "send HTTP_FIRSTNAME to this other application on the same server". You do mention single sign-on, so I'm guessing that you want your app to act as a front-end to this application in question - and to others.

    There's probably no really simple solution if the target application *really* requires the credentials to be sent as HTTP headers. The most obvious way is to implement it as a proxy, i.e. your single sign-on app will forward requests to the target application, with the HTTP headers in question added, and then get the responses and forward them to the requesting client. This does raise some other issues, so it's usually not trivial to implement.

    Perhaps there are mitigating circumstances, can you please explain the requirements further?

    Saturday, June 9, 2007 1:33 PM
  • User-881571857 posted

    The target application in place was written by a vendor.  Their requirements  to send client data to thier application is via HTTP headers.  So for example, if a user registers via my application (I collect First Name, LastName, Email, etc...), I need to set custom HTTP headers that conatins this data so the target application can read these.

     It is not the preferred way I wanted to do this, but I am stuck with what is in place already.

    The tagret application is a J2EE application while the registration application is going to be ASP.NET 2.0

     Both applications would be in the same domain, so the URLS would be for the Registration and Target Application would look like...

    http://www.mydomain.com/Registration

    http://www.mydomain.com/TargetApplication

     Thanks for your quick response.

     

     


     

    Saturday, June 9, 2007 7:55 PM
  • User-225114762 posted

    I think you should try the reverse proxy option. There's a really simple skeleton available here: http://www.codeproject.com/aspnet/HTTPReverseProxy.asp . You should be able to use that for a proof of concept. If the target application renders HTML with absolute URLs you may need to do some rewriting of the outgoing HTML, otherwise you won't get subsequent requests to your proxy.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, June 10, 2007 4:09 AM
  • User-881571857 posted

     Looks interesting...

     Thanks again for the reply, I will try this out and post back here with my results.
     

    Sunday, June 10, 2007 10:29 AM