473,804 Members | 3,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.x ml">
<system.web>
<customErrors mode="On" defaultRedirect ="~/RedirectSiteMap .aspx" />
</system.web>
</location>

or

<location path="sitemap.x ml">
<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 3560
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_ms n_DOT_comwrote in message
news:eR******** ******@TK2MSFTN GP06.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.x ml">
<system.web>
<customErrors mode="On" defaultRedirect ="~/RedirectSiteMap .aspx" />
</system.web>
</location>

or

<location path="sitemap.x ml">
<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="Syst em"/>
<add namespace="Syst em.Configuratio n"/>
<add namespace="Syst em.Data"/>
<add namespace="Syst em.Data.SqlClie nt"/>
<add namespace="Syst em.Web.UI"/>
<add namespace="Syst em.Xml"/>
<add namespace="Syst em.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
2131
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 "http://www.blurb.com/default.asp?test=sweet+%26+sour" actually comes back after the redirect with the % urlencoded which obviously considering its been given the encoding anyway is a nightmare.. ie "http://www.blurb.com/default.asp?test=sweet+%2526+sour"
2
1904
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 would like to redirect/intercept the output of transCore class to this GUI class. I wrote a sample program that demonstrate how I did it, but I am not sure if it's any good. Can anyone critic my code? If there's any non-standard conforming code or...
1
2346
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 shell. Using my Java program I get:
6
6942
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 that either the sub did a redirect or a specific value was specified in the URL. If neither a redirect was done and a certain value was
3
5109
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. Page2 or Page3 will then do some user verification and depending on success/failure redirect again to Page1(failure) or Page4(success) So far i managed to implement sending the data with webrequest, but the problem comes with redirection.
9
2563
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 why. Can anyone explain?
15
3145
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
8831
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 any way to redirect system()'s stdout directly to an internal memory buffer before issuing the call? Thanks, -- John Forkosh ( mailto: j@f.com where j=john and f=forkosh )
9
1834
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 missing page. Most visitors don't describe the link or the page they came from (containing the dead link) so I really would like to prefill their email with the URL of the page that seems to be missing. All ideas are welcome...
2
2590
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. Thanks Richard <%@Language=VBScript%> <% SiteNameURL = Request.ServerVariables("SERVER_NAME")
0
9705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9576
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10567
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10310
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10074
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2983
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.