Saturday, July 16, 2022

Create robots.txt in .Net Core application

 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();  }

No comments:

Post a Comment

How to relate custom pagetype to cms_Document?

SELECT DocumentName,NodeAliasPath,name,Link,custom_property.region,Photo from View_CMS_Tree_Joined JOIN CONTENT_Article on DocumentForeignKe...