|
4 | 4 | using System.Web.Mvc; |
5 | 5 | using System.Xml; |
6 | 6 | using SmartStore.Core; |
| 7 | +using SmartStore.Core.Data; |
7 | 8 |
|
8 | 9 | namespace SmartStore.Services.Seo |
9 | 10 | { |
@@ -48,18 +49,21 @@ public string Generate(UrlHelper urlHelper) |
48 | 49 |
|
49 | 50 | public void Generate(UrlHelper urlHelper, Stream stream) |
50 | 51 | { |
51 | | - _writer = new XmlTextWriter(stream, Encoding.UTF8); |
52 | | - _writer.Formatting = Formatting.Indented; |
53 | | - _writer.WriteStartDocument(); |
54 | | - _writer.WriteStartElement("urlset"); |
55 | | - _writer.WriteAttributeString("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9"); |
56 | | - _writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); |
57 | | - _writer.WriteAttributeString("xsi:schemaLocation", "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"); |
| 52 | + using (var scope = new DbContextScope(autoDetectChanges: false, forceNoTracking: true)) |
| 53 | + { |
| 54 | + _writer = new XmlTextWriter(stream, Encoding.UTF8); |
| 55 | + _writer.Formatting = Formatting.Indented; |
| 56 | + _writer.WriteStartDocument(); |
| 57 | + _writer.WriteStartElement("urlset"); |
| 58 | + _writer.WriteAttributeString("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9"); |
| 59 | + _writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); |
| 60 | + _writer.WriteAttributeString("xsi:schemaLocation", "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"); |
58 | 61 |
|
59 | | - GenerateUrlNodes(urlHelper); |
| 62 | + GenerateUrlNodes(urlHelper); |
60 | 63 |
|
61 | | - _writer.WriteEndElement(); |
62 | | - _writer.Close(); |
| 64 | + _writer.WriteEndElement(); |
| 65 | + _writer.Close(); |
| 66 | + } |
63 | 67 | } |
64 | 68 |
|
65 | 69 | #endregion |
|
0 commit comments