Compare commits
3 Commits
57f7cb28a5
...
f6f75d364f
Author | SHA1 | Date | |
---|---|---|---|
|
f6f75d364f | ||
|
ecf537fdca | ||
|
3655495dfd |
10
Pages/Robots.txt.cshtml
Normal file
10
Pages/Robots.txt.cshtml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
@page
|
||||||
|
@{
|
||||||
|
Layout = null;
|
||||||
|
this.Response.ContentType = "text/plain";
|
||||||
|
}
|
||||||
|
User-agent: *
|
||||||
|
Disallow: /freedom
|
||||||
|
Disallow: /account
|
||||||
|
Disallow: /Account
|
||||||
|
sitemap: https://mydarlingunderwear.ru/sitemap.xml
|
21
Pages/Sitemap.xml.cshtml
Normal file
21
Pages/Sitemap.xml.cshtml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
@page "/sitemap.xml"
|
||||||
|
@using Microsoft.AspNetCore.Http
|
||||||
|
@{
|
||||||
|
var pages = new List<dynamic>
|
||||||
|
{
|
||||||
|
new {Url = "https://mydarlingunderwear.ru/", LastUpdated = DateTime.Today}
|
||||||
|
};
|
||||||
|
Layout = null;
|
||||||
|
Response.ContentType = "text/xml";
|
||||||
|
await Response.WriteAsync("<?xml version='1.0' encoding='UTF-8' ?>");
|
||||||
|
}
|
||||||
|
|
||||||
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
|
@foreach (var p in pages)
|
||||||
|
{
|
||||||
|
<url>
|
||||||
|
<loc>@p.Url</loc>
|
||||||
|
<lastmod>@p.LastUpdated.ToString("yyyy-MM-dd")</lastmod>
|
||||||
|
</url>
|
||||||
|
}
|
||||||
|
</urlset>
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using MyDarling.Models;
|
using MyDarling.Models;
|
||||||
using MyDarling.Services;
|
using MyDarling.Services;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using MyDarling.Controllers;
|
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
@ -28,7 +27,6 @@ builder.Services.Configure<IdentityOptions>( opts =>
|
|||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.AddTransient<IImageResizer, ImageResizer>();
|
builder.Services.AddTransient<IImageResizer, ImageResizer>();
|
||||||
builder.Services.AddScoped<IRobotsTxtGenerator, RobotsTxtGenerator>();
|
|
||||||
builder.Services.AddControllersWithViews();
|
builder.Services.AddControllersWithViews();
|
||||||
builder.Services.AddRazorPages();
|
builder.Services.AddRazorPages();
|
||||||
|
|
||||||
@ -39,10 +37,6 @@ app.MapControllers();
|
|||||||
app.MapDefaultControllerRoute();
|
app.MapDefaultControllerRoute();
|
||||||
app.MapRazorPages();
|
app.MapRazorPages();
|
||||||
|
|
||||||
var robotsScope = app.Services.CreateScope();
|
|
||||||
var robotsGenerator = robotsScope.ServiceProvider.GetService<IRobotsTxtGenerator>();
|
|
||||||
app.MapGet("/robots.txt", () => robotsGenerator!.GetRobotsText());
|
|
||||||
|
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
IdentitySeedData.CreateAdminAccount(app.Services, app.Configuration);
|
IdentitySeedData.CreateAdminAccount(app.Services, app.Configuration);
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace MyDarling.Controllers;
|
|
||||||
|
|
||||||
public class RobotsTxtGenerator : IRobotsTxtGenerator
|
|
||||||
{
|
|
||||||
public string GetRobotsText()
|
|
||||||
{
|
|
||||||
StringBuilder stringBuilder = new();
|
|
||||||
stringBuilder.AppendLine("user-agent: *");
|
|
||||||
stringBuilder.AppendLine("Disallow: /freedom");
|
|
||||||
stringBuilder.AppendLine("Disallow: /Account/");
|
|
||||||
stringBuilder.AppendLine("Disallow: /account/");
|
|
||||||
|
|
||||||
return stringBuilder.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace MyDarling.Controllers;
|
|
||||||
|
|
||||||
public interface IRobotsTxtGenerator
|
|
||||||
{
|
|
||||||
public string GetRobotsText();
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user