homepage Welcome to WebmasterWorld Guest from 54.205.14.21
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Referring URL messages for ASP 404 error page
How do I carry out the same function as #echo var in ASP?
bouncybunny




msg:4375029
 1:22 am on Oct 16, 2011 (gmt 0)

I use a few bits of code in my error 404 pages on a Linux servers. But I would also like to be able to replicate this on an IIS server.

Does anyone know a way to do the following Linux/Apache commands on an IIS hosted website? Iíve been banging my head on the table trying to get this to work, but Iíve never really got my head around it.

Previous location
<!--#echo var="HTTP_REFERER" -->

Requested URL
<!--#echo var="REQUEST_URI" -->

IP address
<!--#echo var="REMOTE_ADDR" -->

Browser
<!--#echo var="HTTP_USER_AGENT" -->

Thanks

 

marcel




msg:4375079
 6:19 am on Oct 16, 2011 (gmt 0)

Request.ServerVariables("HTTP_REFERER")

[w3schools.com...]

bouncybunny




msg:4375113
 11:56 am on Oct 16, 2011 (gmt 0)

Thanks for that.

bouncybunny




msg:4375285
 1:59 am on Oct 17, 2011 (gmt 0)

Hmmm. For some reason I am getting 'StartTag: invalid element nameĎ errors for this;

<%Response.Write(Request.ServerVariables("URL"))%>

It works OK, if I call the 404.asp page directly by typing it into the browser bar. But when used as an error page, it gives the above error.

Any ideas anyone?

Ocean10000




msg:4375451
 1:35 pm on Oct 17, 2011 (gmt 0)

try this instead.
<% = Request.ServerVariables("URL")%>

bouncybunny




msg:4378990
 4:16 am on Oct 25, 2011 (gmt 0)

Thanks for that suggestion.

Same problem, unfortunately. How irritating. The page loads, but stops loading at the point where that line of ASP code starts.

bouncybunny




msg:4379026
 5:37 am on Oct 25, 2011 (gmt 0)

I donít know if it means anything, but it also gives those errors if it finds any Ďlooseí </span> tags in the document.

Ocean10000




msg:4379398
 11:34 pm on Oct 25, 2011 (gmt 0)

What Web browser are you using by chance?

bouncybunny




msg:4379426
 1:03 am on Oct 26, 2011 (gmt 0)

Safari on a Mac. I didnt think to check it on another browser, but will do so later.

bouncybunny




msg:4382382
 1:04 am on Nov 2, 2011 (gmt 0)

OK, Iíve tried this on Firefox on a Mac - which gives its own error page and IE 8 on W7, which loads the page fine, but simply disregards any of the ASP.

Ocean10000




msg:4382545
 1:36 pm on Nov 2, 2011 (gmt 0)

I just had a thought.

The actual error page, is the file extension aspx or asp or html?

If it is html extension IIS will not run any server side scripts. Which I think may be the actual problem you are seeing.

You would have to rename the 404 Page extension to aspx, and update the reference in IIS to point to this version. And retest it.

bouncybunny




msg:4383892
 9:23 pm on Nov 5, 2011 (gmt 0)

Thanks. The filename is .asp. But I'll try aspx and see if that helps.

bouncybunny




msg:4384311
 5:06 am on Nov 7, 2011 (gmt 0)

Hmmmm.

No, unfortunately using .asp or .aspx doesnít solve the problem.

If I call the page directly e.g. www.example.com/404.aspx then the script Ďseems' to kind of work.

e.g.
Sorry, the page <%Response.Write(Request.ServerVariables("URL"))%> has not been found! will display as "Sorry, the page /404.aspx has not been found!".

But if I go to a non-existent page, I get the above errors.

marcel




msg:4384362
 11:37 am on Nov 7, 2011 (gmt 0)

How have you set up the Error page is IIS. Is it as a file or a URL? (if it's set up as a file, it will not run ASP script)

bouncybunny




msg:4384643
 12:26 am on Nov 8, 2011 (gmt 0)

Aha. Thanks, I'll check that out later. I'm pretty sure I set it as a file.

bouncybunny




msg:4384703
 5:27 am on Nov 8, 2011 (gmt 0)

OK, thatís fantastic. It works!

Thanks for all your help people.

Just one final question.

When I try to use
<%Response.Write(Request.ServerVariables("URL"))%> or <% = Request.ServerVariables("URL")%>

Instead of returning the url of the page the user was trying to find, it returns the name of the 404 page. E.G.
Sorry, the page /404.asp has not been found
instead of
Sorry, the page /missing.html has not been found
.

Any ideas?

wingnut




msg:4389339
 11:16 am on Nov 21, 2011 (gmt 0)

The code will not execute if you using the default 404 page as it is a static page (.htm).

Look at this article [support.microsoft.com...]

bouncybunny




msg:4399971
 6:52 am on Dec 21, 2011 (gmt 0)

Thanks. I am using a static page, with a .asp extension.

What I found is that the code which displays the referring page URL works fine, but the code which displays the sought after page URL doesnít.

However, as the result of another issue, Iíve discovered that the biggest problem is that this method doesnít send a 404 error from the server. It actually returns an ĎOKí found message. So Iíve had to abandon this idea for the time being, and used a .HTML file without any asp code, which sends the correct error. Unless anyone has any suggestions.

Thanks for all the help.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved