このウェブサイトには、ビザ申請モジュールもあります。ビザ申請モジュールでは、ユーザーがアカウントを作成する必要があります。ユーザーが添付ファイルをアップロードするたびに、添付ファイル内の特定のフォルダーに保存されます。この特定のフォルダーは、各ユーザーに割り当てられた一意に生成された番号に対応しています。
ここで必要なのは、ユーザーがログインしていない場合、添付ファイル フォルダー内のファイルにアクセスできないようにすることです。
httpハンドラーを使用してそれを達成するにはどうすればよいですか?
私はこのコードを持っています
if (HttpContext.Current.Session["UserRegistrationID"] != null)
{
if (HttpContext.Current.Session["UserRegistrationID"].ToString() != "")
{
DownloadFile(context);
}
else
{
context.Response.Write("You don't have the rights to access this file.");
context.Response.Flush();
}
}
else
{
context.Response.Write("You don't have the rights to access this file.");
context.Response.Flush();
}
protected void DownloadFile(HttpContext context)
{
context.Response.ContentType = "image/jpg";
context.Response.WriteFile(context.Request.PhysicalPath);
context.Response.Flush();
}
しかし、問題は、Web 構成での構成に問題があることです。
誰もこれを行う方法を知っていますか?