Differences
This shows you the differences between two versions of the page.
— | it:ad:patterns:secure_the_line_strategy [2023/11/04 03:29] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | # IT: | ||
+ | |||
+ | |||
+ | |||
+ | <callout type=" | ||
+ | |||
+ | * [[../ | ||
+ | {{indexmenu> | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | ## Summary ## | ||
+ | |||
+ | Using [[IT/# | ||
+ | |||
+ | |||
+ | |||
+ | ## Process ## | ||
+ | |||
+ | Therefore it's useful to have a way to ensure that all communications with the server are over HTTPS. | ||
+ | |||
+ | |||
+ | ### MVC ### | ||
+ | |||
+ | |||
+ | #### Using an Attribute Over the Action ### | ||
+ | |||
+ | |||
+ | <sxh csharp> | ||
+ | using System; | ||
+ | using System.Linq; | ||
+ | using System.Net.Http; | ||
+ | using System.Web.Http.Filters; | ||
+ | using System.Web.Http.Controllers; | ||
+ | |||
+ | namespace WebAPI | ||
+ | { | ||
+ | | ||
+ | { | ||
+ | public override void OnActionExecuting(HttpActionContext actionContext) | ||
+ | { | ||
+ | if (!String.Equals(actionContext.Request.RequestUri.Scheme, | ||
+ | { | ||
+ | actionContext.Response = new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest) | ||
+ | { | ||
+ | | ||
+ | }; | ||
+ | return; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ## References | ||
+ | |||
+ | * http:// | ||
+ | |||
+ | |||
+ | |||