セッションを使用して汎用ハンドラー (upload.ashx) からアップロードされたファイル名を取得しようとすると、問題ありません。samepage で webmethod を使用することもでき、uploadify はうまく機能しますが、Session["fileName"] が null になっています。私のコードに何か問題がありますか? ファイル名を取得するために汎用ハンドラーを使用するだけでよいですか?
[WebMethod(EnableSession = true)]
public void LoadPicture(HttpContext context)
{
try
{
HttpPostedFile file = context.Request.Files["Filedata"];
context.Session["fileName"] = file.FileName;
...................いくつかのリサイズと画像コードの保存....
context.Response.Write("1");
}
catch (Exception ex)
{
context.Response.Write("0");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
using (_modelService = new ModelService())
{
ModelEntity _models = new ModelEntity();
......some codes....
_models.modelphoto = Session["fileName"].ToString();
_modelService.ModelAdd(_models);
}
}