Skip to content

Instantly share code, notes, and snippets.

View mishrsud's full-sized avatar
🎯
Focusing

Sudhanshu Mishra mishrsud

🎯
Focusing
View GitHub Profile
@mishrsud
mishrsud / HostedService.cs
Created November 5, 2018 03:29 — forked from davidfowl/HostedService.cs
A base class that allows writing a long running background task in ASP.NET Core 2.0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
namespace WebApplication24
{
public abstract class HostedService : IHostedService

.NET Core 2.0 SDK Preview 1 Support in Visual Studio for Mac

This document covers the steps required in order to use build and run .NET Core 2.0 and .NET Standard 2.0 projects with Visual Studio for Mac.

Existing project templates target .NET Core 1.1

If only the .NET Core 2.0 SDK is installed then the projects will fail to run due to the 1.1 runtime being unavailable. To target .NET Core 2.0 the TargetFramework in the project will need to be edited to target netcoreapp2.0 or netstandard2.0. Alternatively the dotnet cli installed with the .NET Core 2.0 SDK can be used to create the project with the correct dependencies and target framework.

.NET Core App 2.0 Project

@mishrsud
mishrsud / UnhandledExceptionLoggingSetup
Last active February 21, 2017 23:18 — forked from gkinsman/new_gist_file
UnhandledExceptionLogger
public static class UnhandledExceptionLogger
{
public static void Install()
{
var log = Log.ForContext(typeof(UnhandledExceptionLogger));
AppDomain.CurrentDomain.UnhandledException += (s, e) =>
{
log.Fatal(e.ExceptionObject as Exception, "Unhandled exception caught at AppDomain boundary (terminating: {IsTerminating})", e.IsTerminating);
};
@mishrsud
mishrsud / HttpRequestMessageHelper.cs
Last active August 29, 2015 14:25 — forked from MikeJansen/HttpRequestMessageHelper.cs
HttpRequestMessage.GetClientIpAddress for ASP.NET MVC 4 / Web API
// Original idea: http://stackoverflow.com/questions/9565889/get-the-ip-address-of-the-remote-host
using System.Net.Http;
using System.ServiceModel.Channels;
using System.Web;
namespace CrowSoftware.Api
{
public static class HttpRequestMessageHelper
{