$/
artifacts/
build/
docs/
lib/
packages/
samples/
src/
tests/
using System; | |
using System.Buffers; | |
using System.Collections.Generic; | |
using System.IO.Pipelines; | |
using System.Linq; | |
using System.Text.Json; | |
using System.Text.Json.Serialization; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.AspNetCore.Mvc.Filters; | |
using Microsoft.AspNetCore.Mvc.Formatters; | |
using Newtonsoft.Json; | |
using Newtonsoft.Json.Serialization; | |
using System; | |
using System.Buffers; | |
namespace MyProject.Filters | |
{ |
internal static class FormsAuthenticationTicketHelper | |
{ | |
private const byte CURRENT_TICKET_SERIALIZED_VERSION = 0x01; | |
private const int MAX_TICKET_LENGTH = 4096; | |
// Resurrects a FormsAuthenticationTicket from its serialized blob representation. | |
// The input blob must be unsigned and unencrypted. This function returns null if | |
// the serialized ticket format is invalid. The caller must also verify that the | |
// ticket is still valid, as this method doesn't check expiration. |
You can now read this on my (pretty) website! Check it out here.
Every reason to get more HackerPoints™ is a good one, so today we're going to
write a neat command line app in .NET Core! The Common library has a really cool
package Microsoft.Extensions.CommandlineUtils
to help us parse command line
arguments and structure our app, but sadly it's undocumented.
No more! In this guide, we'll explore the package and write a really neat
Have a repository on GitHub? Planning on making a repository on GitHub? This checklist is intended to introduce you to various features that may help you make the most of your GitHub repository with specific recommendations for C# repositories.
These are only suggestions.
They may not be appropriate for all repositories.
They are in no particular order.
Click each item to expand for more information.
// Copyright (c) .NET Foundation. All rights reserved. | |
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | |
using System; | |
using System.Buffers; | |
using System.Collections.Concurrent; | |
using System.Collections.Generic; | |
using System.Net; | |
using System.Threading; | |
using System.Threading.Tasks; |
public void FormsAuthentication_OnAuthenticate(object sender, FormsAuthenticationEventArgs args) | |
{ | |
var machineKeySection = (MachineKeySection) WebConfigurationManager.GetWebApplicationSection("system.web/machineKey"); | |
var cookie = args.Context.Request.Cookies[".ASPXAUTH"]; | |
if (cookie == null || !Regex.IsMatch(cookie.Value, "^([a-fA-F0-9]{2})+$")) | |
return; | |
var cookieBytes = ByteUtility.ToBytes(cookie.Value); | |
int signatureLength; |