This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://drive.google.com/uc?export=download&id=1n7Ji3ca9V9PgSud36-QNR0fU44r95YKr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MessageAttribute : ActionFilterAttribute { | |
// Tell Ninject to inject the type | |
[Inject] | |
public IMessageService MessageService {get; set;} | |
public override void OnActionExecuted(ActionExecutedContext filterContext) { | |
var actionName = filterContext.ActionDescriptor.ActionName; | |
filterContext.Controller.ViewModel.FilterMessage = MessageService.GetMessage(actionName); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class InjectableFilterProvider : FilterAttributeFilterProvider { | |
public IKernel Kernel { get; private set; } | |
public InjectableFilterProvider(IKernel kernel) { | |
Kernel = kernel; | |
} | |
public override IEnumerable<Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) { | |
var filters = base.GetFilters(controllerContext, actionDescriptor); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Owin; | |
using Owin; | |
using Microsoft.Owin.Security; | |
using Microsoft.Owin.Security.Cookies; | |
using Microsoft.Owin.Security.OpenIdConnect; | |
using System.Threading.Tasks; | |
using Microsoft.IdentityModel.Protocols.OpenIdConnect; | |
using System.Configuration; | |
using System.Security.Claims; | |
using IdentityModel.Client; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Owin; | |
using Owin; | |
using System.Threading.Tasks; | |
[assembly: OwinStartup(typeof(OWINSample.Startup))] | |
namespace OWINSample | |
{ | |
public class Startup | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.HttpOverrides; | |
var builder = WebApplication.CreateBuilder(args); | |
// Add services to the container. | |
builder.Services.AddRazorPages(); | |
// Configure the Forwarded Headers | |
builder.Services.Configure<ForwardedHeadersOptions>(options => | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There's a *free* domain we can all leverage called http://localtest.me . ~All~ subdomains resolve | |
to 127.0.0.1. You can make ~any~ subdomain you want without having to go to some admin page or | |
account page and 'creating' it. Just go and try: ping whateverYouWant.localtest.me and it should | |
resolve to 127.0.0.1 ! Awesome! For more info: http://readme.localtest.me/ | |
2. Make sure your machine can accept this domain, etc. | |
a) Run command line AS ADMIN. | |
b) type => netsh http add urlacl url=http://create-some-subdomain-here.localtest.me:1337/ user=everyone | |
3. Add this binding to your website. | |
a) IIS: Just open up IIS -> your website -> Bindings -> add the domain name. | |
b) IIS Express: open up \\MyDocuments\IISExpress\config\application.config ... and look for the <sites> element (around line 155). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// snippet around reading from HttpRequest.Body | |
var request = context.Request; | |
request.EnableBuffering(); | |
// deserialize into temp structure using System.Text.Json.JsonSeralizer | |
var temp = await JsonSerializer.DeserializeAsync<RequestTemp>(request.Body, | |
options: new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); | |
request.Body.Seek(0, SeekOrigin.Begin); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get current branch in git repo | |
function parse_git_branch() { | |
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` | |
if [ ! "${BRANCH}" == "" ] | |
then | |
STAT=`parse_git_dirty` | |
echo "[${BRANCH}${STAT}]" | |
else | |
echo "" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Invokers : ActionInvokerRegistry { | |
public Invokers() { | |
// Define an expression for which to search the registered list | |
Expression<Fun<RequestContext, ControllerInfo, bool>>> fooSelector = | |
(context, info) => return info.ControllerName == "Foo"; | |
// Register the invoker -> selector for the engine to know | |
Use<FooInvoker>(fooSelector); |
NewerOlder