I have a WCF REST service with Azure Blob Storage. I don't want to use my service as a proxy with a stream, so I wanted to redirect client's request to the absolute blob url but it redirects to the file and tries to open it directly. All I want is starting download process when server redirects the request to the absolute blob url. The code which I have tried is below:
var sas = blob.GetSharedAccessSignature(new SharedAccessPolicy
{
Permissions = SharedAccessPermissions.Read,
SharedAccessStartTime = DateTime.UtcNow,
SharedAccessExpiryTime = DateTime.UtcNow + TimeSpan.FromMinutes(1)
});
WebOperationContext.Current.OutgoingResponse.ContentType = blob.Properties.ContentType;
WebOperationContext.Current.OutgoingResponse.ContentLength = blob.Properties.Length;
WebOperationContext.Current.OutgoingResponse.Location = blob.Uri.AbsoluteUri+sas;
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Redirect;
P.S. I tried to change status code to Redirect, Moved.. etc. but nothing changes.
Update If I change ContentType to application/octet-stream, it results like this in IE:
<base64Binary xmlns="http://schemas.microsoft.com/2003/10/Serialization/">
...
</base64Binary>