Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7178375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:54:31+00:00 2026-05-28T16:54:31+00:00

I am trying to dynamically create a sitemap for my site and I wan’t

  • 0

I am trying to dynamically create a sitemap for my site and I wan’t it to be (I believe it is necessary to have it) located at the root level, ie. Domain.com/sitemap.xml
So far I have an action result in the home controller like this:

public ActionResult SiteMap()
{
    ...
    return this.Content(xml, "text/xml");
}

This works fine for creating the file but it is located at Domain.com/Home/Sitemap and my understanding is the the sitemap is supposed to be located at the root level. Is there a way to rewrite the url or add a new route for it in the Global.asax file? By default the Global.asax file contains this:

routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

So it seems like this may be the place to add something like a check if the requested route is Sitemap.xml and just redirect it to Home/sitemap (or just serve the sitemap right there). I’m not sure how to do this, if it is possible, as I have never messed around with the RegisterRoutes section.

Another problem that may arise would be the extension .xml, I would think that IIS would think this is a file on the drive and ignore the route all together.

Am I going down the correct path, or is there a better way to do this? Or is it not possible and I have to just physically create the file?

Edit (Solved)
I just occurred to me that I have been thinking about this the wrong way. All I would have to do is have a method to create/update a sitemap file and save it to /sitemap.xml periodicity or every time a page is added. I can’t believe this wasn’t obvious to me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:54:32+00:00Added an answer on May 28, 2026 at 4:54 pm

    You could add a route:

    routes.MapRoute(
        "sitemap",
        "sitemap.xml",
        new { controller = "Home", action = "SiteMap" }
    );
    

    and make sure that you put this route before your default route.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to dynamically create COM object, call COM method and set COM
I'm trying to dynamically create domain objects in Grails and encountered the problem that
I am trying to dynamically create module level functions from the methods in a
i'm trying to create dynamically generated icon list for tiny mce. I have written
I'm trying to dynamically create a navbar from data i fetch from a web
I'm trying to dynamically create alert messages using the jQuery plugin for Bootstrap CSS.
I'm trying to dynamically create a link from a Windows Form to our website
I am trying to dynamically create an XML file using php like this: header
I'm trying to dynamically create a set of labels in my XUL Runner application.
I'm trying to dynamically create a connection string during compile time: private static string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.