SELECT DocumentName,NodeAliasPath,name,Link,custom_property.region,Photo from View_CMS_Tree_Joined
JOIN CONTENT_Article on DocumentForeignKeyValue = ArticleID and ClassName ='custom.property'
where ##where## Order by ##orderby##
Create Robots.txt file in .net core
SELECT DocumentName,NodeAliasPath,name,Link,custom_property.region,Photo from View_CMS_Tree_Joined
JOIN CONTENT_Article on DocumentForeignKeyValue = ArticleID and ClassName ='custom.property'
where ##where## Order by ##orderby##
using Business.Services;
using Core.Configuration;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using SimpleMvcSitemap;
using System;
using System.Collections.Generic;
using XperienceAdapter.Localization;
namespace ABC.Controllers
{
[Route("googlesitemap.xml", Name = "GoogleSitemap")]
public class GoogleSitemapController : BaseController
{
private readonly ISitemapServices _sitemapServices;
public GoogleSitemapController(ILogger<BaseController> logger,
IOptionsMonitor<XperienceOptions> optionsMonitor,
IStringLocalizer<SharedResource> stringLocalizer,
ISitemapServices sitemapServices) : base(logger, optionsMonitor, stringLocalizer)
{
_sitemapServices = sitemapServices ?? throw new ArgumentNullException(nameof(sitemapServices));
}
public IActionResult Index()
{
var contentMultiple = _sitemapServices.GetContentAsync(
_optionsMonitor.CurrentValue.CacheInSeconds,
null
);
List<SitemapNode> nodes = new List<SitemapNode>();
foreach (var doc in contentMultiple.Result)
{
nodes.Add(new SitemapNode(doc.NodeAliasPath)
{
LastModificationDate = (doc.DocumentModifiedWhen.Date)
});
}
return new SitemapProvider().CreateSitemap(new SitemapModel(nodes));
}
}
}
You can use middleware for creating robots.txt in .net core,
Here is my code for robots.txt
Code:-
Installed Nuget package
PM> Install-Package RobotsTxtCore
Open -> startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddStaticRobotsTxt(builder =>
builder
.AddSection(section =>
section
.AddUserAgent("*")
.Allow("/")
)
.AddSitemap(SiteContext.CurrentSite.SitePresentationURL + "googlesitemap.xml")
);
}
public void Configure(IApplicationBuilder app)
{ app.UseRobotsTxt(); }
SELECT DocumentName,NodeAliasPath,name,Link,custom_property.region,Photo from View_CMS_Tree_Joined JOIN CONTENT_Article on DocumentForeignKe...