Home > Net >  C # WebApi one interface one session will be called many times, how to determine whether the session
C # WebApi one interface one session will be called many times, how to determine whether the session

Time:05-02

The following code, WebApi provides an interface to download, but each visit only once this interface, this interface will repeat trigger multiple times, causing me to write logs, originally only visit once download interface, the same session has written many times the same download records, what identity can be judged whether repeated requests the same session?
 
[HttpGet]Public HttpResponseMessage DownFile ([FromUri] string fileGuid, [FromUri] string fileName, [FromUri] string sign)
{
Var file=Path.Com bine (ConfigHelper GetInventoryFileSaveDirectory (), HttpUtility. UrlDecode (fileGuid), HttpUtility. UrlDecode (fileName));
FileStream stream=new FileStream (file, FileMode. Open, FileAccess. Read);
{
HttpResponseMessage result=new HttpResponseMessage (System.Net.HttpStatusCode.OK);
result.Content=new StreamContent(stream);
Result. The Content. The Headers. ContentType=new System.Net.Http.Headers.MediaTypeHeaderValue (" application/octet stream - ");
Result. The Content. The Headers. ContentDisposition=new System.Net.Http.Headers.ContentDispositionHeaderValue (" attachment ")
{
FileName=HttpUtility. UrlEncode (Path. GetFileName (file))
};
//download log records, the same session will call

return result;
}
}
  •  Tags:  
  • C#
  • Related