473,379 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Redirect non-existing sitemap.xml file to ASPX page

Okay, this is driving me nuts now. I spent all last night researching newsgroup postings, web articles, etc.

Running multiple sites off the same shared hosting service, I want to be able to redirect a non-existing siteinfo.xml and sitemap.xml to appropriate ASPX pages that will return valid XML for the domain accessed.

I don't understand httpModules and httpHandlers very well but they don't seem to be what I need. There was discussion about using 404 redirects, but I can't seem to get this to work either.

What I currently have set up (which doesn't seem to work) is:

<location path="sitemap.xml">
<system.web>
<customErrors mode="On" defaultRedirect="~/RedirectSiteMap.aspx" />
</system.web>
</location>

or

<location path="sitemap.xml">
<system.web>
<customErrors mode="On" defaultRedirect="~/RedirectSiteMap.aspx">
<error statusCode="404" redirect="~/RedirectSiteMap.aspx" />
</customErrors>
</system.web>
</location>

This fails to work on localhost and on the deployed site. Ideas? What am I missing. I know others have said they have this working?

Running ASP.NET 2.0

Thanks!

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )
Sep 20 '06 #1
3 3530
Hey Greg,

Your first code snippet works for me. When I try to access the non-existent
sitemap.xml file, ASP.NET redirects to the page RedirectSiteMap.aspx.

Could you explain more about what is going wrong? Does it not redirect at
all? What error do you see?

Ken
Microsoft MVP [ASP.NET]

"Greg Collins [Microsoft MVP]" <gcollins_AT_msn_DOT_comwrote in message
news:eR**************@TK2MSFTNGP06.phx.gbl...
Okay, this is driving me nuts now. I spent all last night researching
newsgroup postings, web articles, etc.

Running multiple sites off the same shared hosting service, I want to be
able to redirect a non-existing siteinfo.xml and sitemap.xml to appropriate
ASPX pages that will return valid XML for the domain accessed.

I don't understand httpModules and httpHandlers very well but they don't
seem to be what I need. There was discussion about using 404 redirects, but
I can't seem to get this to work either.

What I currently have set up (which doesn't seem to work) is:

<location path="sitemap.xml">
<system.web>
<customErrors mode="On" defaultRedirect="~/RedirectSiteMap.aspx" />
</system.web>
</location>

or

<location path="sitemap.xml">
<system.web>
<customErrors mode="On" defaultRedirect="~/RedirectSiteMap.aspx">
<error statusCode="404" redirect="~/RedirectSiteMap.aspx" />
</customErrors>
</system.web>
</location>

This fails to work on localhost and on the deployed site. Ideas? What am I
missing. I know others have said they have this working?

Running ASP.NET 2.0

Thanks!

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )

Sep 20 '06 #2
Strange. I'm not sure what could be wrong then.

For both localhost and remote host, I get the 404 page (forgive me for duplicating it here):

The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
--------------------------------------------------------------------------------

Please try the following:

a.. Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly.
b.. If you reached this page by clicking a link, contact the Web site administrator to alert them that the link is incorrectly formatted.
c.. Click the Back button to try another link.
HTTP Error 404 - File or directory not found.
Internet Information Services (IIS)

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

Technical Information (for support personnel)

a.. Go to Microsoft Product Support Services and perform a title search for the words HTTP and 404.
b.. Open IIS Help, which is accessible in IIS Manager (inetmgr), and search for topics titled Web Site Setup, Common Administrative Tasks, and About Custom Error Messages.

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )
Sep 20 '06 #3
Maybe this is entirely related, but I also recently tried adding default namespaces into the web.config file:

<pages>
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Configuration"/>
<add namespace="System.Data"/>
<add namespace="System.Data.SqlClient"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Xml"/>
<add namespace="System.Xml.Xsl"/>
</namespaces>
</pages>

But when I tried to remove such references from my code behind pages:

using System;
using System.Web.UI;
using System.Xml;
using System.Xml.Xsl;

Then the page doesn't load anymore, telling me, for example:

Compiler Error Message: CS0246: The type or namespace name 'Page' could not be found (are you missing a using directive or an assembly reference?)
Perhaps these are related issues?

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )
Sep 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tim | last post by:
response.redirect seems to urlencode a querystring thrown across at it.. is there a way to disable this function that anyone knows of? ie.. response.redirect...
2
by: Jason | last post by:
Hello, I have a class, transCore, that does certain work, and by default, prints its progress to the stand output. Later, I will to write a GUI class that encapsulate the transCore class. I...
1
by: iksrazal | last post by:
Hi all, I've been struggling to make this command work from Java: /usr/bin/mysql c4 --user=root --password=mypass -e "source /home/crissilva/c4.sql" Works fine as shown when run from the...
6
by: Peter Row | last post by:
Hi, I am writing a DLL in VB.NET that implements IHttpHandler.ProcessRequest. This code calls a sub and I need to know if that sub did a response redirect or not. Specifically I need to know...
3
by: Mario | last post by:
Greetings! Here is the problem i'm facing. I'm supposed to read some user input on Page1, then, depends on what the user inputs, redirect him to Page2 or Page3 and send the entered data with it....
9
by: jeremy | last post by:
In a web app I'm develing for PDA's, I'm using javascript for navigation. (document.location = "url"). I've seen a bunch of posts on the groups saying this is a bad idea, but no explanations...
15
by: John | last post by:
Hello, I have a php contact script and I want it to redirect to my homepage without using the standard header command. <?php header("location:http://www.johndoe.com/index.html"); exit;
6
by: JohnF | last post by:
I'd like to capture the stdout output from system("command") in a buffer. Although system("command >tmpnam") and then open,read,remove tmpnam works, it's a bit more messy than I'd like. Is there...
9
by: M | last post by:
Hello all, We've got the following problem: When a visitor klicks a dead link he ends up on a 404-page like should be. On that page there's an opportunity to mail the webmaster (me) about the...
2
by: fran7 | last post by:
Hi, I have this select redirect that doesnt work, only the case else works, anyone see whats wrong with it? Its basically to redirect my dynamic pages to their new homes. Any help appreciated....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.