将 web.config 文件放置在视图目录中
我在生产环境中遇到标准问题超时异常,90 秒后,线程将被终止。 对于我网站的绝大多数来说,这不是问题。
然而,我的站点地图生成器是一个例外。
因为它依赖于应用程序中创建的路由,所以我选择在项目内创建它,因为它从应用程序加载所有路由,然后有效地使用自定义的 Html.Action 来生成每个路由。
因为创建整个站点地图需要相当长的时间(最后一次统计为 5 分钟),所以在它有机会完成之前我就收到了 YSOD。 现在,在 webforms 中,我只需在目录中创建一个 web.config,并使用 location 元素:
<configuration>
<location path="sitemapgenerator">
<system.web>
<httpRuntime executionTimeout="600" /><!-- Ten minutes -->
</system.web>
</location>
</configuration>
如果没有实际创建这个配置文件,我相信,这不仅行不通,而且在 MVC 中也是非常糟糕的做法,因为它然后将站点地图生成器的命名限制为配置文件中设置的任何内容,而不仅仅是路由。
如果需要更改,我可以确保路由和配置文件保持最新,但这在 MVC 中看起来很混乱。
任何人都可以给我任何关于此的建议,以及此 web.config 方法是否有效?
提前谢谢了。
更新:我对此进行了测试,不,它不起作用,所以我也没有后备解决方案。 :)
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. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过在站点地图生成器的初始化中设置 scriptTimeout 属性?
服务器.ScriptTimeout = 600;
Have you tried setting the scriptTimeout property in the initialization of the site map generator?
Server.ScriptTimeout = 600;