download and install Solr from http://lucene.apache.org/solr/.
you can access Solr admin from your browser: http://localhost:8983/solr/
use the port number used in installation.
| public class ApiLoggingMiddleware | |
| { | |
| private readonly RequestDelegate _next; | |
| public ApiLoggingMiddleware(RequestDelegate next) | |
| { | |
| _next = next; | |
| } | |
| public async Task InvokeAsync(HttpContext context) |
download and install Solr from http://lucene.apache.org/solr/.
you can access Solr admin from your browser: http://localhost:8983/solr/
use the port number used in installation.
| <# | |
| Azure Automation Runbook to Stop Azure VM | |
| Setup the following variables in Azure Automation Runbook: | |
| SubscriptionName, SubscriptionID, CertificateName, VMName | |
| Import a certificate as well | |
| #> | |
| workflow Stop-VM | |
| { | |
| $VMName = "equinox" | |
| $subscriptionName = Get-AutomationVariable -Name "SubscriptionName" |
| git config --global diff.tool bc4 | |
| git config --global difftool.bc4.path "c:/Program Files/Beyond Compare 4/bcomp.exe" | |
| git config --global merge.tool bc4 | |
| git config --global mergetool.bc4.path "c:/Program Files/Beyond Compare 4/bcomp.exe" |
| public static class XmlDocumentPrettyExtension | |
| { | |
| public static string Prettyify(this XmlDocument xmlDocument) | |
| { | |
| var stringWriter = new StringWriter(new StringBuilder()); | |
| var xmlTextWriter = new XmlTextWriter(stringWriter) { Formatting = Formatting.Indented }; | |
| xmlDocument.Save(xmlTextWriter); | |
| return stringWriter.ToString(); | |
| } | |
| } |
| private SqlConnection GetSqlConnection(DbContext dbContext) | |
| { | |
| var ec = dbContext.Database.Connection; | |
| var adoConnStr = ec.ConnectionString; | |
| return new SqlConnection(adoConnStr); | |
| } |
| /* Useful for analyzing a Elmah logs stored in a SQL Server */ | |
| /* Version 1 */ | |
| /* --------------------------------------------------------------*/ | |
| DECLARE @StartDateTime datetime | |
| DECLARE @EndDateTime datetime | |
| DECLARE @HourlyThreshold int -- If error count for an hour is greater than this number display in the threshold overflow report | |
| SET @HourlyThreshold = 10 | |
| SET @StartDateTime = DATEADD(d, -7, CAST(GETDATE() AS date)) |
| # Generate Cert and Key in seperate file | |
| # Provide the .cert to the end user | |
| openssl req -new -newkey rsa:1024 -days 365 -nodes -x509 -keyout QA.key -out QA.cert | |
| # Merge cert and private key to make a p12 file, this file will be used by .NET's X509Certificate2 class, The private key will be accessible via the "PrivateKey" property | |
| openssl pkcs12 -export -in qa.cert -inkey qa.key -out qa.p12 -name "QA" |
| <% | |
| ' Use with a very short session (basically the page lifecycle, GET then POST) | |
| Class AntiForgeryValidator | |
| Private m_securityToken | |
| Sub SetCookie() | |
| m_securityToken = CreateWindowsGuid() | |
| Response.Cookies("RequestVerificationToken") = m_securityToken |
| public ActionResult LogOff() | |
| { | |
| // Load Identity Configuration | |
| FederationConfiguration config = FederatedAuthentication.FederationConfiguration; | |
| // Get wtrealm from WsFederationConfiguation Section | |
| string wtrealm = config.WsFederationConfiguration.Realm; | |
| string wreply; | |
| // Construct wreply value from wtrealm (This will be the return URL to your app) |