0
我们有这个网站,我们也有签证申请模块。签证申请模块要求用户创建一个帐户。每当用户上传附件时,它都会保存在附件中的特定文件夹中。该特定文件夹对应于分配给每个用户的唯一生成的数字。限制直接访问我们的附件文件夹
现在我需要的是如果用户没有登录他们不应该能够访问附件文件夹内的文件。
我该如何实现使用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();
}
但问题是我有在网络配置配置方面的问题。
有谁知道如何做到这一点?