Search code examples
asp.netashx

Form post data to ASHX hidden fields


I have next form and some ashx

 <form action="FileUpload.ashx" method="POST" enctype="multipart/form-data" id="frmUpload">
        <input id="fileupload" type="file" name="files[]" />
        <input id="viewId" type="hidden" />
        <input id="moduleId" type="hidden" />
        <button id="btnUpload" type="submit">Upload</button>
    </form>

I can get file inside of ProcessRequest(HttpContext context) context.Request.Files - file containe file information, but context.Request.Form["viewId"] is empty. That should I do to get hidden fields values ?

Thanks.


Solution

  • You need to add the name="viewid" also. The name attribute is used when you make post, not the id

    read also: HTML input - name vs. id in the line "Used on form elements to submit information"