Dreams
Dreams
CC#
Created by Dreams on 12/24/2022 in #help
Enabling caching in Nginx
Etag caching works for the static files, and I'd like to do the same for my API request/responses
4 replies
CC#
Created by Dreams on 12/24/2022 in #help
Enabling caching in Nginx
/etc/nginx/nginx-SalonML.conf:
server {
listen 80;
listen [::]:80;
server_name salonmlsarajevo.com;
return 301 https://salonmlsarajevo.com$request_uri;
}

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;

ssl_certificate /etc/letsencrypt/live/salonmlsarajevo.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/salonmlsarajevo.com/privkey.pem;

server_name salonmlsarajevo.com;

try_files $uri $uri/ /index.html @proxy;

location @proxy {
proxy_pass http://127.0.0.1:83;
}

root /var/www/SalonML/;
index index.html;
autoindex off;
}
server {
listen 80;
listen [::]:80;
server_name salonmlsarajevo.com;
return 301 https://salonmlsarajevo.com$request_uri;
}

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;

ssl_certificate /etc/letsencrypt/live/salonmlsarajevo.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/salonmlsarajevo.com/privkey.pem;

server_name salonmlsarajevo.com;

try_files $uri $uri/ /index.html @proxy;

location @proxy {
proxy_pass http://127.0.0.1:83;
}

root /var/www/SalonML/;
index index.html;
autoindex off;
}
4 replies
CC#
Created by Dreams on 12/24/2022 in #help
Enabling caching in Nginx
/etc/nginx/nginx-SalonML_API.conf:
server {
listen 80;
listen [::]:80;
server_name api.salonmlsarajevo.com;
return 301 https://api.salonmlsarajevo.com$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;

ssl_certificate /etc/letsencrypt/live/salonmlsarajevo.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/salonmlsarajevo.com/privkey.pem;

server_name api.salonmlsarajevo.com;

root /var/www/SalonML_API/;
index index.html;
autoindex off;

location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;

proxy_cache_bypass $http_upgrade;

proxy_set_header Connection $http_connection;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Server $host;
}
}
server {
listen 80;
listen [::]:80;
server_name api.salonmlsarajevo.com;
return 301 https://api.salonmlsarajevo.com$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;

ssl_certificate /etc/letsencrypt/live/salonmlsarajevo.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/salonmlsarajevo.com/privkey.pem;

server_name api.salonmlsarajevo.com;

root /var/www/SalonML_API/;
index index.html;
autoindex off;

location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;

proxy_cache_bypass $http_upgrade;

proxy_set_header Connection $http_connection;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Server $host;
}
}
4 replies
CC#
Created by Dreams on 12/24/2022 in #help
Nginx serving static files with ETag but not ASPNET requests
ok thank you! @mtreit
3 replies
CC#
Created by Dreams on 12/24/2022 in #help
❔ Linq statement doesn't work
ah..
10 replies
CC#
Created by Dreams on 12/24/2022 in #help
❔ Linq statement doesn't work
10 replies
CC#
Created by Dreams on 12/24/2022 in #help
❔ Linq statement doesn't work
System.InvalidOperationException: The LINQ expression 's => EntityShaperExpression:
SalonML_API.Data.Models.DynamicContent
ValueBufferExpression:
ProjectionBindingExpression: EmptyProjectionMember
IsNullable: False
.Name.Contains(s)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
at Microsoft.EntityFrameworkCore.Query.RelationalSqlTranslatingExpressionVisitor.VisitLambda[T](Expression`1 lambdaExpression)
System.InvalidOperationException: The LINQ expression 's => EntityShaperExpression:
SalonML_API.Data.Models.DynamicContent
ValueBufferExpression:
ProjectionBindingExpression: EmptyProjectionMember
IsNullable: False
.Name.Contains(s)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
at Microsoft.EntityFrameworkCore.Query.RelationalSqlTranslatingExpressionVisitor.VisitLambda[T](Expression`1 lambdaExpression)
10 replies
CC#
Created by Dreams on 12/24/2022 in #help
❔ Linq statement doesn't work
this is my entire code:
[HttpGet]
public async Task<IActionResult> GetContent([FromQuery] string[]? strArray)
{
// ** todo get this to order by OrderIndex **
List<DynamicContentDTO> dynContentList;

if (strArray == null)
dynContentList = await _context.DynamicContents
.OrderBy(x => x.OrderIndex)
.Select(d => new DynamicContentDTO(d))
.ToListAsync();
else
dynContentList = await _context.DynamicContents
.OrderBy(x => x.OrderIndex)
.Where(i => strArray.Any(s => i.Name.Contains(s)))
//.Where(i => i.Name.Contains(substring[0]))
.Select(d => new DynamicContentDTO(d))
.ToListAsync();

return Ok(dynContentList);
}
[HttpGet]
public async Task<IActionResult> GetContent([FromQuery] string[]? strArray)
{
// ** todo get this to order by OrderIndex **
List<DynamicContentDTO> dynContentList;

if (strArray == null)
dynContentList = await _context.DynamicContents
.OrderBy(x => x.OrderIndex)
.Select(d => new DynamicContentDTO(d))
.ToListAsync();
else
dynContentList = await _context.DynamicContents
.OrderBy(x => x.OrderIndex)
.Where(i => strArray.Any(s => i.Name.Contains(s)))
//.Where(i => i.Name.Contains(substring[0]))
.Select(d => new DynamicContentDTO(d))
.ToListAsync();

return Ok(dynContentList);
}
10 replies
CC#
Created by Dreams on 12/23/2022 in #help
Linq to select where Name contains substring?
wow it worked!
8 replies
CC#
Created by Dreams on 12/23/2022 in #help
Linq to select where Name contains substring?
ok thank you
8 replies
CC#
Created by Dreams on 12/23/2022 in #help
Linq to select where Name contains substring?
ah
8 replies
CC#
Created by Dreams on 12/23/2022 in #help
Linq to select where Name contains substring?
i'm helpless with Linq
8 replies
CC#
Created by Dreams on 12/20/2022 in #help
❔ How to connect to Azure Key Vault from external VPS?
this is in my Program.cs:
if (builder.Environment.IsProduction())
{
builder.Configuration.AddAzureKeyVault(
new Uri($"https://{builder.Configuration["KeyVaultName"]}.vault.azure.net/"),
new DefaultAzureCredential());
}
if (builder.Environment.IsProduction())
{
builder.Configuration.AddAzureKeyVault(
new Uri($"https://{builder.Configuration["KeyVaultName"]}.vault.azure.net/"),
new DefaultAzureCredential());
}
4 replies
CC#
Created by Dreams on 12/20/2022 in #help
❔ Azure VM network very slow
comes out to 1.3 Mbps ... like why
5 replies
CC#
Created by Dreams on 12/20/2022 in #help
❔ Azure VM network very slow
i'm using the $9.50/month VM
5 replies
CC#
Created by Dreams on 12/16/2022 in #help
❔ Help with EF Core Linq statement
thank you @Angius i learned something
21 replies
CC#
Created by Dreams on 12/16/2022 in #help
❔ Help with EF Core Linq statement
sorting first then grouping makes sense
21 replies
CC#
Created by Dreams on 12/16/2022 in #help
❔ Help with EF Core Linq statement
i see
21 replies
CC#
Created by Dreams on 12/16/2022 in #help
❔ Help with EF Core Linq statement
var dynContentList = await _context.DynamicContents
.OrderByDescending(x => x.OrderIndex)
.Select(d => new DynamicContentDTO(d))
.GroupBy(x => x.Name)
.ToListAsync();
var dynContentList = await _context.DynamicContents
.OrderByDescending(x => x.OrderIndex)
.Select(d => new DynamicContentDTO(d))
.GroupBy(x => x.Name)
.ToListAsync();
21 replies
CC#
Created by Dreams on 12/16/2022 in #help
❔ Help with EF Core Linq statement
System.InvalidOperationException: The LINQ expression 'DbSet<DynamicContent>()
.OrderByDescending(x => x.OrderIndex)
.Select(d => new DynamicContentDTO(d))
.GroupBy(x => x.Name)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
System.InvalidOperationException: The LINQ expression 'DbSet<DynamicContent>()
.OrderByDescending(x => x.OrderIndex)
.Select(d => new DynamicContentDTO(d))
.GroupBy(x => x.Name)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
21 replies