fenixblades
fenixblades
CC#
Created by fenixblades on 11/13/2023 in #help
ADFS - only show certain claims provider trusts for ONE relying party and not all of them?
I have the following sites:
https://example.com/ClientA
https://example.com/ClientB
https://example.com/ClientC
https://example.com/ClientA
https://example.com/ClientB
https://example.com/ClientC
Right now if I go to https://example.com/ClientA then I'm sent to https://adfsco.example.com/adfs/ls?... and there is the claims providers we trust for that site. Now I'd like to have it so when https://example.com/ClientB is navigated to, the user would see different providers that only matter for that site. I've seen things about home realm discovery pages, but no step-by-step guide explaining how to actually wire this up. I'm assuming one ADFS can handle this, but not sure how. Is this where relying parties come in?
1 replies
CC#
Created by fenixblades on 9/14/2023 in #help
❔ IIS urlrewrite not working
I have a simple web.config for an index.html page like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to /foo/" stopProcessing="true">
<match url="^foo/(.*)" />
<action type="Redirect" url="/foo/" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
<defaultDocument>
<files>
<clear />
<add value="index.html" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to /foo/" stopProcessing="true">
<match url="^foo/(.*)" />
<action type="Redirect" url="/foo/" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
<defaultDocument>
<files>
<clear />
<add value="index.html" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
If I navigate to https://example.com/foo/REMOVE_ME then I get a 404 because /foo/REMOVE_ME is not a valid resource. I feel like this rewrite is very simple and should be correct, but I'm clearly missing something. Any ideas? Note, this is on a web app on my site. So the site is example.com and the web app is foo. IIS treeview looks like this:
server
> application pools
> sites
> example.com
> foo
index.html
web.config
server
> application pools
> sites
> example.com
> foo
index.html
web.config
2 replies
CC#
Created by fenixblades on 3/1/2023 in #help
❔ Serilog file sink from multiple servers has interleaved messages
I have a web app deployed across 10 web servers. They are all configured as such (note, the path below is a shared network path. So they are all pointing to the same log file):
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "Console"
},
{
"Name": "File",
"Args": {
"shared": true,
"path": "logs/foo_.log",
"rollingInterval": "Day",
"retainedFileCountLimit": 7
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ]
},
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "Console"
},
{
"Name": "File",
"Args": {
"shared": true,
"path": "logs/foo_.log",
"rollingInterval": "Day",
"retainedFileCountLimit": 7
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ]
},
However I'm noticing the log file has interleaved messages:
2023-02-28 00:03:16.105 -06:00 [DBG] Execution plan of result filters (in the following order): ["Microsoft.AspNetCore.Mvc.Infrastructure.C2023-02-28 00:03:16.054 -06:00 [INF] Requ2023-02-28 00:03:16.130 -06:00 [DBG] Execution plan of result filters (in the following order):
Notice the [DBG] and [INF] log levels in the same message, and this here here specifically:
Infrastructure.C2023-02-28 00:03:16.054 -06:00 [INF] Requ2023-02-28 00:03:16.13
How can I prevent this from happening? I thought shared: true was the support Serilog needed to handle this situation?
10 replies
CC#
Created by fenixblades on 12/13/2022 in #help
❔ Log from helper class without creating new context? (Serilog)
I have a bunch of services with their own dedicated loggers that have config'd settings for filtering based on that exact type:
{
"Name": "Logger",
"Args": {
"Filter": [
{
"Name": "ByIncludingOnly",
"Args": { "expression": "SourceContext = 'FooNamespace.BarClass'" }
}
]
}
}
{
"Name": "Logger",
"Args": {
"Filter": [
{
"Name": "ByIncludingOnly",
"Args": { "expression": "SourceContext = 'FooNamespace.BarClass'" }
}
]
}
}
This way, I can setup output log files for each service individually. Now I have a helper class that all of the services utilize, and I want to add logging to this helper class, but I want the logs to appear in the log file that the calling service already has going. Since the filtering above is based on type, I'm not sure how to wire this up. Right now my helper class is setup to use DI like:
public class Helper
{
private readonly ILogger<Helper> _logger;
public Helper(ILogger<Helper> logger) => _logger = logger;
}
public class Helper
{
private readonly ILogger<Helper> _logger;
public Helper(ILogger<Helper> logger) => _logger = logger;
}
But this seems to create a new logger for Helper specifically, which isn't caught by the calling service's logger filtering.
5 replies
CC#
Created by fenixblades on 12/10/2022 in #help
✅ Any modern approach to getting the calling class typename aside from using the stack frame?
10 years ago I used to use the stack frame to go backwards and get what class is calling my current method. I know there's attributes as well, but they are more physical file based. Is there a modern approach in current .NET to getting this information at runtime? Such as for a logger method that's trying to find out what called it?
5 replies
CC#
Created by fenixblades on 11/11/2022 in #help
❔ Why wont visual studio auto format this with CTRL K + CTRL D?
can anyone think of why visual studio wont format these lambda arrows with CTRL K + CTRL D but it will format things around it like spacing between semicolons?
var exportBatchInputs = new List<TbExportBatchInput>()
{
TestHelper.Fixture.Build<TbExportBatchInput>()
.With(c => c.ExportBatchId, TestHelper.BatchID)
.With(c=>c.FieldName, "PO Box") // note the spacing between the fat arrow here
.With(c=>c.FieldData, "12345") // note the spacing between the fat arrow here
.Create()
};
var exportBatchInputs = new List<TbExportBatchInput>()
{
TestHelper.Fixture.Build<TbExportBatchInput>()
.With(c => c.ExportBatchId, TestHelper.BatchID)
.With(c=>c.FieldName, "PO Box") // note the spacing between the fat arrow here
.With(c=>c.FieldData, "12345") // note the spacing between the fat arrow here
.Create()
};
if i do something like this
var foo = ()=>5;
var foo = ()=>5;
it correctly auto formats it to
var foo = () => 5;
var foo = () => 5;
so im not sure what the difference is in context between those 2 that would cause visual studio to not format the first instance.
4 replies
CC#
Created by fenixblades on 11/2/2022 in #help
❔ Anyone know of or use an open source pdfimage viewer + editor for the web? Using asp mvc core
Looking for standard pdf editor type controls like view, annotate, append/remove pages, etc, but for a web browser. Preferably one that integrations with .NET
12 replies
CC#
Created by fenixblades on 9/9/2022 in #help
Anyone have experience or know of an open source barcode reading library for images?
There's of course a bunch of paid options, but I'm looking for an open source alternative if one exists.
4 replies