I have a Controller that lets a user that logged in can download a file that has been purchased.
In My Controller I have an action like bellow
//My custom attribute that authorizes user
[FrontPanelAuthorize(Roles="user")]
public ActionResult GetFile(int fileId,string password)
{
try
{
//hashes password
Hasher hash = new Hasher();
var hashPass = hash.MD5HashForPassword(password, "");
//getting current logged in user
var Us = _useRepository.GetByFirst(n => n.Username == User.Identity.Name);
//getting current file to download
var file = _useRepository.Db.Theme.FirstOrDefault(n => n.ThemeId== fileId).ThemeFile;
if (Us.Password == hashPass)
{
if (IsAuthorizedToDownload(fileId))
{
//preparing file to download and getting the directory of the file
FileDownloader fileToDl = new FileDownloader();
var fileDirecory = fileToDl.PrepareFileToDownload(Us, file);
//returning file
return new FilePathResult(fileDirecory,"application.zip")
{
FileDownloadName = file.FileName
};
}
return new Http403Result();
}
return new Http403Result();
}
catch
{
return HttpNotFound();
}
}
I can get file in firefox well,but when I want to get file via Internet Download Manager I get 403 Forbidden Error,
I also checked with breakpoints,It sends me to HandleUnauthorizedRequest() Method of my authorize attribute,
I want to know if there is a way that lets a user can log in via internet download manager or force an unauthenticated user to log in in Internet Download Manager.
I Appreciate Your Help,
Update* Http403Result called from HandleUnauthorizedRequest() in FronPanelAuthorizeAttribute class
public class FrontPanelAuthorizeAttribute:AuthorizeAttribute
{
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
filterContext.Result = new Http403Result();
}
}