Skip to content

Instantly share code, notes, and snippets.

View tugberkugurlu's full-sized avatar
:shipit:
💥 shakalaka

Tugberk Ugurlu tugberkugurlu

:shipit:
💥 shakalaka
View GitHub Profile
@tugberkugurlu
tugberkugurlu / HttpContentProcessor.cs
Created July 2, 2012 21:36 — forked from HenrikFrystykNielsen/HttpContentProcessor.cs
Sample showing a DelegatingHandler which plugs in a special HttpContent wrapper for saving response content to local disk and perform asynchronous post-processing on that file. This allows content from a response to be post-processed, for example to send
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
namespace ResponseEntityProcessor.Handlers
{
/// <summary>
/// Wraps an inner <see cref="HttpContent"/> and forces the content to be written
@tugberkugurlu
tugberkugurlu / gist:3698733
Created September 11, 2012 14:05 — forked from darrelmiller/gist:3698177
A replacement for the old HttpResponseMessage<T>
public class HttpResponseMessage<T> : HttpResponseMessage
{
public HttpResponseMessage(HttpRequestMessage request, T value)
{
var config = request.GetConfiguration();
var contentNegotiator = config.Services.GetContentNegotiator();
var connegResult = contentNegotiator.Negotiate(
typeof(T), request, config.Formatters
);
request.CreateResponse(HttpStatusCode.Accepted, value);
@tugberkugurlu
tugberkugurlu / gist:3720631
Created September 14, 2012 07:54 — forked from darrelmiller/gist:3698325
Some Web API techniques
using System;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.SelfHost;
namespace WebApiSelfHost
{
class Program
{
@tugberkugurlu
tugberkugurlu / Documents\IISExpress\config\applicationhost.config
Created September 18, 2012 14:01 — forked from prabirshrestha/DocumentsIISExpressconfigapplicationhost.config
Allows IISExpress site to be externally accessed (e.g. by VM or iOS device)
<site name="WebSite1" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="C:\PathToWebSite" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":1151:localhost" />
<binding protocol="http" bindingInformation="*:1151:pswin8mac.local" />
</bindings>
</site>
cmd /C "webpicmdline\webpicmdline.exe /AcceptEula /SuppressReboot /Products:WindowsInstaller31"
cmd /C "webpicmdline\webpicmdline.exe /AcceptEula /SuppressReboot /Products:WindowsInstaller45"
# Powershell
cmd /C "webpicmdline\webpicmdline.exe /AcceptEula /SuppressReboot /Products:PowerShell"
cmd /C "webpicmdline\webpicmdline.exe /AcceptEula /SuppressReboot /Products:PowerShell2"
# .NET
cmd /C "webpicmdline\webpicmdline.exe /AcceptEula /SuppressReboot /Products:NETFramework20SP2"
cmd /C "webpicmdline\webpicmdline.exe /AcceptEula /SuppressReboot /Products:NETFramework35"
@tugberkugurlu
tugberkugurlu / UrlHelperTest.cs
Created September 26, 2012 17:45 — forked from mwrock/UrlHelperTest.cs
Testing UrlHelper.Route
//This is test setup
var mockTeamFoundationFeatureAvailabilityService = new Mock<ITeamFoundationFeatureAvailabilityService>();
var testable = new ApiFeatureAvailabilityController(x => mockTeamFoundationFeatureAvailabilityService.Object);
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost:8080/path");
var config = new HttpConfiguration();
config.Routes.MapHttpRoute("FeatureAvailability", "path/{id}", new { Controller = "ApiFeatureAvailability", id = RouteParameter.Optional });
request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
request.Properties[HttpPropertyKeys.HttpRouteDataKey] = config.Routes.GetRouteData(request);
testable.Url = new UrlHelper(request);
testable.Request = request;
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
This shows how you can get the name of the generated assembly when building a project
using the MSBuild task.
Note: the result of this is shown at https://dl.dropbox.com/u/40134810/twitter/msbuild-target-outputs.png
-->
<!-- The .csproj/.vbproj files to build, this can be named whatever you want -->
@tugberkugurlu
tugberkugurlu / gist:3836733
Created October 4, 2012 21:56 — forked from benfoster/gist:3836636
Membership without the cruft.
/// <summary>
/// Represents a username/password type login
/// </summary>
public class FabrikLogin
{
public const string FabrikLoginProviderId = "fabrik";
/// <summary>
/// A unique identifier for the login.
/// </summary>
@tugberkugurlu
tugberkugurlu / gist:3848310
Created October 7, 2012 12:53 — forked from benfoster/gist:3847790
Injecting HttpRequestMessage in ASP.NET Web API
public IHttpController Create(
HttpRequestMessage request,
HttpControllerDescriptor controllerDescriptor,
Type controllerType)
{
var scope = request.GetDependencyScope() as StructureMapDependencyScope;
// Inject the current request into the underlying container
scope.Container.Inject<HttpRequestMessage>(request);