Skip to content

Instantly share code, notes, and snippets.

@sasan-salem
Created November 11, 2019 12:34
Show Gist options
  • Save sasan-salem/f2bfc901a4ff02b1761c168940acc0b7 to your computer and use it in GitHub Desktop.
Save sasan-salem/f2bfc901a4ff02b1761c168940acc0b7 to your computer and use it in GitHub Desktop.
namespace DotNet.Controller
{
public class DummyBytesController : ApiController
{
[HttpGet]
public HttpResponseMessage Get()
{
HttpResponseMessage Response;
string UserAgent = HttpContext.Current.Request.UserAgent;
if(UserAgent.Contains("Instagram"))
{
Response = new HttpResponseMessage(HttpStatusCode.OK);
Response.Content = new ByteArrayContent(new byte[50]);
Response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
return Response;
}
else
{
Response = Request.CreateResponse(HttpStatusCode.Redirect);
Response.Headers.Location = new Uri("https://mywebsite.com");
return Response;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment