Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Header Error

Status
Not open for further replies.

MaryumS

Programmer
Oct 31, 2000
12
US
I am trying to add authentication level login pages to my website. However, when I try to redirect the user to another page if they don't have the proper user level to view the page I get a Header Error that looks like such:

Header Error

/Project1/securitylevel2required.asp, line 5

The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.

Securitylevel2required.asp page looks like such:
<%
if session(&quot;securitylevel&quot;) > 1 Then
'do nothing
Else
Response.Redirect &quot;securityunauthorized.asp&quot;
end If
%>

Now, I found in the forum the same situation in which the person who responded posed the solution to use Response.Buffer at the top of the page. I tried this and I still get the same error but this time the error refers to the line containing the statement 'Response.buffer'.

If anyone has a solution to this it would be greatly appreciated.

Thanks in advance,
M
 
This is normally because you have normal html tags before the Response.Redirect. Is your ASP code at the very top of your page - before EVERYTHING else?? If not, try moving your authentication script to the very top, so that you page looks like this:

<%
' asp code to authenticate user
if session(&quot;securitylevel&quot;) > 1 Then
'do nothing
Else
Response.Redirect &quot;securityunauthorized.asp&quot;
end If
%>
<html>
<head>
......
</html>
Simon
 
There are no html tags on the page where the error is occuring. The only code is the If statement.

-M
 
make sure that your response.Buffer is set to true at the top of the pages and also make sure that the location of the page is correct i.e. the directory is where you say it is? Other than that I don't see anything wrong with your code

Walt III
SAElukewl@netscape.net
 
I used the Response.Buffer = true at the top of the page but again I got the exact same error but this time the error was refering to the line containing the statement Response.Buffer = true.

If Anyone has encountered this error and has a solution,please, I would really appreciate it. Nothing I have tried has worked, so far.

Thx,
M
 
Well, what is supposed to happen when their security level is < 1?

There have to be some html tags being written somewhere (whether it's obvious or not), because I have gotten that exact same error before, and that is always the problem.

The html tags could be the result of one of your condition statements that you aren't expecting???

Try viewing the source of the page after you get the error and double checking to see if there are any html tags, and tracking those down.

Hope it helps,
paul prewett
 
Make Sure that You Have the Response.Buffer = True inside of ASP tags all the way at the top of your HTML Page. And that You have it on every page that Uses Redirect.

<%Language = VBScript
Option Explicit
Response.Buffer = True %>
<HTML>...

Walt III
SAElukewl@netscape.net
 
Now, I had a title tag at the top of the asp page that includes the file holding the code with the redirect. But, when I remove the tag the browser says it cannot find the page, eventhough the page defately exists in the directory that I am calling.

Any suggestions as to why it may be doing this?

Thanks,
M
 
This is some of the code for the page which calls the include file containing the redirect statement.

<%@ LANGUAGE=&quot;VBSCRIPT&quot; %>
<title></title>

<!--#include file=&quot;../securitylevel1required.asp&quot;-->

<%

reportname = &quot;Record Assign.rpt&quot;

%>

<!-- #include file=&quot;../ProjectFiles/AlwaysRequiredSteps.asp&quot; -->

%>

<!-- #include file=&quot;../ProjectFiles/MoreRequiredSteps.asp&quot; -->

The Code to the securitylevel1required looks as so:
<%
Response.buffer = true
if session(&quot;securitylevel&quot;) > 1 Then
'do nothing
Else
Response.clear
Response.Redirect &quot;securityunauthorized.asp&quot;
Response.end
end If
%>

The problem, obviously, is with the html tag of title. But if I take that out the browser just tells me that the page cannot be found. I tried moving the response.buffer = true to the top of the first asp page but the browser stilltells me the page cannot be found.

The rest of the include files worked just fine before trying to include any of the new stuff.

 
Try taking the response.buffer = true and put it right under the Language tag. I have always been told that You have to set the buffer to true at the top of the page. How far from the top your allowed to do this I don't know. Also Try changing your if statement.
Sometimes the computer will just act wierd if you don't do anything in an if statement and have an else. Eliminate the else and change the '>' to '<'. Sorry I'm not more helpful.

Walt III
SAElukewl@netscape.net
 
I have already tried that, I have tried putting the response.buffer = true in every possible place. That doesn't seem to be the problem. The problem is that it doesn't even go into the page once I take the title tags out from the first line or put anything above them. The browser doesn't recognize the page as existing once I take the tags out.

Does anyone have any suggestions?
 
try this one

&amp;#64; in the code is the at sign

Code:
 <%@Language=VBScript %>
<%Response.buffer = true%>

<title></title>

<!--#include file=&quot;../securitylevel1required.asp&quot;-->
                                                               
<%

reportname = &quot;Record Assign.rpt&quot;

%>

<!-- #include file=&quot;../ProjectFiles/AlwaysRequiredSteps.asp&quot; -->                       

%>

<!-- #include file=&quot;../ProjectFiles/MoreRequiredSteps.asp&quot; -->

'The Code to the securitylevel1required looks as so:
<%
if session(&quot;securitylevel&quot;) > 1 Then
    'do nothing
Else
    Response.Redirect &quot;securityunauthorized.asp&quot;
End If 
%>

regards ::) Unicorn11
abhishek@tripmedia.com

[red]Life is a stream who's source is hidden[red]
 
try this one

and i dont know if the response.redirect can be in a seperate asp file so i think that you should put that also in the same asp file like below

@ in the code is the at sign

Code:
 <% &amp;#64; Language=VBScript %>
<%Response.buffer = true%>
<%
if session(&quot;securitylevel&quot;) > 1 Then
    'do nothing
Else
    Response.Redirect &quot;securityunauthorized.asp&quot;
End If 
%>
<title></title>
<%
reportname = &quot;Record Assign.rpt&quot;
%>

<!-- #include file=&quot;../ProjectFiles/AlwaysRequiredSteps.asp&quot; -->                       
%>
<!-- #include file=&quot;../ProjectFiles/MoreRequiredSteps.asp&quot; -->

'The Code to the securitylevel1required looks as so:

regards ::) Unicorn11
abhishek@tripmedia.com

[red]Life is a stream who's source is hidden[red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top