Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

ASP.NET (vb.net) custom HTTP headers

Posted on 2010-11-15
5
803 Views
Last Modified: 2012-08-13
Hi All,

The wider picture to this problem is the integration of an ASP.NET application with Google Apps - but that is a way down the line for now.

All I am trying to do at this stage is append the HTTP Header of a page and pass it to another page (which is the basic premise of Google AuthSub for Google Apps).

In the following file: http://www.********.com/header1.aspx I have the following Sub Page_Load:

---------------------------------------

Sub Page_Load(Sender As Object, E As EventArgs)
      
        Response.AppendHeader("Test", "Test")
      
      Response.Redirect("header2.aspx")
      
End Sub

---------------------------------------

The simplest of things that *should* add the header "Test" to the GET Request for "header2.aspx". However, header2.aspx does not output a header value called "Test"!

Header 2 simply has this in the body:

---------------------------------------

<%= Request.ServerVariables("ALL_HTTP") %>

---------------------------------------

This is mad because it's so simple which is kind of why I am lost - there is not much documentation online for such a straightforward issue.

Any help will be massively appreciated.
0
Comment
Question by:courtthree
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:sandipshah
ID: 34142060
I am not much of an ASP geek, but why don't you use Python / Java?  Everything that you need is already implemented there.

And Google is trying to move everything to OAuth ... if you can, stay away from ClientLogin & AuthSub.

Ss
0
 
LVL 21

Assisted Solution

by:Alfred1
Alfred1 earned 500 total points
ID: 34142457
0
 
LVL 6

Author Comment

by:courtthree
ID: 34143244
Thanks Alfred,

That does start to point me in the right direction but the solution offered in that link doesn't work directly.

Given the nature of this code block:

---------------------------------------

Sub Page_Load(Sender As Object, E As EventArgs)
     
        Response.AppendHeader("Test", "Test")
        Response.Redirect("header2.aspx")
     
End Sub

---------------------------------------

Can you tell me how the redirect should work?
0
 
LVL 21

Accepted Solution

by:
Alfred1 earned 500 total points
ID: 34144017
Have you seen the following link:

http://www.asp101.com/tips/index.asp?id=161


or you could try the following:

Response.AppendHeader("Refresh", "2; URL=header2.aspx");

or you could just put this in your ASP.NET page source:

<head>
<META HTTP-EQUIV="refresh" CONTENT="2;URL=header2.aspx; text/html; charset=us-ascii;">
</head>
0
 
LVL 6

Author Comment

by:courtthree
ID: 34144784
Thank you for your continued input but I have no discovered that using the methids described above send the headers as "Response" and Google requires "Request" objects!

I have now written the following which gets me through Google authentication:

---------------------------------------------------

<script runat="server">

Dim t As String

Sub Page_Load(Sender As Object, E As EventArgs)

      t = Request.QueryString("token")
      
      Dim googleRequest = HttpWebRequest.Create("https://www.google.com/accounts/AuthSubSessionToken")
      googleRequest.Method = "GET"
      googleRequest.Headers.Set("Authorization", "AuthSub token=""" & t & """")
      Dim googleResponse = googleRequest.GetResponse()
      
      outputLabel.Text = googleResponse.toString()
      
End Sub

</script>

---------------------------------------------------

The problem I now have is accessing the content of the "googleRequest.GetResponse()" method.

However, I realise that your previous answers were correct for the original question so I think it would only be fair if I accept your answer and post this as a new question. By all means, go and answer the new one!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A few customers have recently asked my thoughts on Password Managers.  As Security is a big part of our industry I was initially very hesitant and sceptical about giving a program all of my secret passwords.  But as I was getting asked about them mo…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question