C# 上载将查询传递给通用处理程序
我在这一部分停留了几天,仍然无法将任何查询字符串传递给通用处理程序 我的代码如下: 第一:查询字符串被传递到Upload.aspx。我在页面加载部分检索它: My Upload.aspx.csC# 上载将查询传递给通用处理程序,c#,javascript,jquery,uploadify,generic-handler,C#,Javascript,Jquery,Uploadify,Generic Handler,我在这一部分停留了几天,仍然无法将任何查询字符串传递给通用处理程序 我的代码如下: 第一:查询字符串被传递到Upload.aspx。我在页面加载部分检索它: My Upload.aspx.cs protected void Page_Load(object sender, EventArgs e) { int userId = Convert.ToInt32(Request.QueryString["userid"]); int upload = Con
protected void Page_Load(object sender, EventArgs e)
{
int userId = Convert.ToInt32(Request.QueryString["userid"]);
int upload = Convert.ToInt32(Request.QueryString["upload"]);
int childId = Convert.ToInt32(Request.QueryString["childid"]);
}
我的上传.aspx
<script type="text/javascript">
// <![CDATA[
$(document).ready(function() {
$('#fileInput').uploadify({
'uploader': 'uploadify/uploadify.swf',
'script': 'Upload.ashx',
'cancelImg': 'uploadify/cancel.png',
'auto': true,
'multi': true,
'fileDesc': 'Image Files',
'fileExt': '*.jpg;*.png;*.gif;*.bmp;*.jpeg',
'queueSizeLimit': 90,
'sizeLimit': 4000000,
'buttonText': 'Choose Images',
'folder': '/uploads',
'onAllComplete': function(event, queueID, fileObj, response, data) {
}
});
如何将查询传递到upload.ashx?其中userId是我试图传递的查询
提前谢谢 在
ProcessRequest
方法中使用此选项。您可以使用Context.Request
获取查询字符串参数
int userId = Convert.ToInt32(Context.Request.QueryString["userid"]);
确保在应用程序web.config
中完成了url映射
例如
可能会让您对编写泛型处理程序有所了解。是的,我已经尝试过了。查询字符串没有从upload.aspx传递到泛型处理程序。因此,这里的userId仍然为null。我已经将其添加到processRequest方法中。但是我在int userId=Convert.ToInt32(context.Request.QueryString[“userId]”)处遇到了一个格式异常;我想这就是问题所在。。。如何添加urlMapping?我已经添加了urlMappings。但同样的错误仍然存在。如您所见,在脚本“:”Upload.ashx”中。我没有通过任何质询。因为我不知道如何将pageload上的查询传递给通用处理程序。在设置URL映射时,不必显式传递querystring参数。
int userId = Convert.ToInt32(Context.Request.QueryString["userid"]);
<system.web>
<urlMappings enabled="true">
<add url="~/Upload.aspx" mappedUrl="~/Upload.ashx"/>
</urlMappings>
...