the name file does not exist in current context in signal r Hub class

404 Views Asked by At

This is my GetFileData with return type FileResult so it should return a file:

public FileResult GetFileData(int fileId)
     {
         var file = db.Files.Single(x => x.Id == fileId);
         return File(file.Content, file.ContentType);
     }

but at last line, its showing red line on File and the error message is--the name file does not exist in current context. what should i do ??

1

There are 1 best solutions below

1
On

First:

SignalR isn't for file transfer, it's for sending messages.

How can I transfer bytes in chunks to clients?

Second: File is not working because its declared in System.Web.Mvc.Controller, a SignalR hub doesn't extend this class. https://msdn.microsoft.com/en-us/library/system.web.mvc.controller(v=vs.118).aspx

A Hub extends Microsoft.AspNet.SignalR.Hub https://msdn.microsoft.com/en-us/library/microsoft.aspnet.signalr.hub(v=vs.118).aspx