views:

186

answers:

1

I am having the standard issue timeout exception in my production environment whereby, after 90 seconds, the thread will be killed. For the vast majority of my site this isn't a problem.

However, my sitemap generator is an exception to the rule.

Because it relies on the routes created in the application, I have chosen to create it inside the project, as it loads all routes in from the app, and then, effectively uses a customised Html.Action to generate each route.

Because it takes a fair while to create the entire sitemap (5 minutes at last count), I get a YSOD before it has a chance to complete. Now, in webforms, I'd just create a web.config in the directory, and a nice little handler for that page using the location element:

<configuration>
  <location path="sitemapgenerator">
    <system.web>
      <httpRuntime executionTimeout="600" /><!-- Ten minutes -->
    </system.web>
  </location>
</configuration>

Without actually creating this config file, I'm convinced that, not only will this not work, but it's also pretty bad practice in MVC anyway, because it then restricts the naming of the sitemap generator to whatever is set in the config file, and not just the routes.

I could just ensure that the routes and the config file stay up-to-date if I need to change it, but this just seems messy in MVC.

Can anyone give me any suggestions about this, and whether this web.config method will work out?

Many thanks in advance.

Update: I've done a test on this, and no, it does not work, so I have no fallback solution either. :)

+3  A: 

Have you tried setting the scriptTimeout property in the initialization of the site map generator?

Server.ScriptTimeout = 600;

James Conigliaro
Yep, that'll be the ticket! :D
Dan Atkinson
Many thanks for your answer!
Dan Atkinson