This file contains hidden or 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 MethodOverrideHandler : DelegatingHandler | |
{ | |
private const string Header = "X-HTTP-Method-Override"; | |
private readonly string[] methods = { "DELETE", "HEAD", "PUT" }; | |
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | |
{ | |
if (request.Method == HttpMethod.Post && request.Headers.Contains(Header)) | |
{ | |
var method = request.Headers.GetValues(Header).FirstOrDefault(); |
This file contains hidden or 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 VersioningFilter : ActionFilterAttribute | |
{ | |
public override void OnActionExecuting(HttpActionContext actionContext) | |
{ | |
var acceptHeaderContents = ...; | |
if (string.IsNullOrWhiteSpace(acceptHeaderContents)) | |
{ | |
actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.NotAcceptable, "No accept header provided"); | |
} | |
else if (!IsCompatibleRequestVersion(acceptHeaderContents)) |
This file contains hidden or 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
[ActionName("Index"), HttpPost] | |
public async Task<HttpResponseMessage> CreateAttachment(...) | |
{ | |
if (!Request.Content.IsMimeMultipartContent()) | |
{ | |
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); | |
} | |
string attachmentsDirectoryPath = HttpContext.Current.Server.MapPath("~/SomeDir/"); | |
if (!Directory.Exists(attachmentsDirectoryPath)) |
This file contains hidden or 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 TypedJsonMediaTypeFormatter : MediaTypeFormatter | |
{ | |
private static readonly JavaScriptSerializer Serializer = new JavaScriptSerializer(); | |
public TypedJsonMediaTypeFormatter(MediaTypeHeaderValue mediaType) | |
{ | |
SupportedMediaTypes.Clear(); | |
SupportedMediaTypes.Add(mediaType); | |
} |
This file contains hidden or 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 TypedXmlMediaTypeFormatter : XmlMediaTypeFormatter | |
{ | |
private readonly int minorApiVersion; | |
public TypedXmlMediaTypeFormatter(MediaTypeHeaderValue mediaType, int minorApiVersion) | |
{ | |
this.minorApiVersion = minorApiVersion; | |
SupportedMediaTypes.Clear(); | |
SupportedMediaTypes.Add(mediaType); | |
} |
This file contains hidden or 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 MvcApplication : HttpApplication | |
{ | |
protected void Application_Start() | |
{ | |
... | |
GlobalConfiguration.Configuration.MessageHandlers.Add(new OptionsHandler()); | |
GlobalConfiguration.Configuration.MessageHandlers.Add(new MethodOverrideHandler()); | |
GlobalConfiguration.Configuration.Formatters.Insert(0, new TypedXmlMediaTypeFormatter ...); | |
GlobalConfiguration.Configuration.Formatters.Insert(0, new TypedJsonMediaTypeFormatter ...); | |
... |
This file contains hidden or 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
[HttpGet] | |
public HttpResponseMessage Foo([FromBody]MyModel bar) | |
{ | |
var queryParams = HttpUtility.ParseQueryString(Request.RequestUri.Query); | |
string q = queryParams["q"]; | |
... | |
} |
This file contains hidden or 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 MvcApplication : HttpApplication | |
{ | |
protected void Application_Start() | |
{ | |
AreaRegistration.RegisterAllAreas(); | |
GlobalConfiguration.Configure(WebApiConfig.Register); | |
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); | |
RouteConfig.RegisterRoutes(RouteTable.Routes); | |
BundleConfig.RegisterBundles(BundleTable.Bundles); | |
} |
This file contains hidden or 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
.flex-video { | |
position: relative; | |
padding-top: 25px; | |
padding-bottom: 67.5%; | |
height: 0; | |
margin-bottom: 16px; | |
overflow: hidden; | |
} | |
.flex-video.widescreen { padding-bottom: 57.25%; } |
This file contains hidden or 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
Blog post - http://ajden.towfeek.se/post/become-your-own-root-certificate-authority-and-create-self-signed-ssl-certificates |
OlderNewer