Form post data to ASHX hidden fields - asp.net

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.

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"

Related

How to form post from C#

I've an aspx form with a form tag as below and this form tag contains some sensitive info with hidden fields
<form id="payment_confirmation" target="myFrame" action='https://testsecureacceptance.cybersource.com/embedded/pay' method="post"/>
<input type="hidden" name="access_key" value="sensitivevalue1">
<input type="hidden" name="profile_id" value="sensitivevalue2">
<input type="hidden" name="transaction_uuid" value="<% Response.Write(getUUID()); %>">
<input type="hidden" name="signed_field_names" value="sensitivevalue3">
<input type="hidden" name="unsigned_field_names" value="card_type,card_number,card_expiry_date">
<input type="hidden" name="signed_date_time" value="<% Response.Write(getUTCDateTime()); %>">
<input type="hidden" name="locale" value="en">
<input type="submit" id="submit" name="submit" value="Submit"/>
</form>
When i click "Submit" it successfully post the values and user is "redirected" into the "https://testsecureacceptance.cybersource.com/embedded/pay" form but those hidden fields values are exposed to users (when they inspect the page). I can encrypt them but is there any other way i can post values and redirect from backend where values will not be exposed to users?
Thanks
In short, no. Hidden fields are only hidden from view on the screen and will always be available be available when viewing the source of the page when you are using web forms like this. You can use the viewstate, which will encode the fields and make them harder to read, but if it is truly sensitive information, you will need to properly encrypt that information.
Hope that helps.

Upload image tag source without using file input

I want to upload <img> tag src in my spring mvc. I have already tried to upload img using input file method. But is it possible to upload a img src to spring controller?
<form method="POST" action="<c:url value='/upload' />"
enctype="multipart/form-data">
Please select a file to upload : <input type="file" name="file" />
<input type="submit" value="upload" />
</form>
I have already uploaded the image using file input tag.
<form method="POST" action="<c:url value='/upload' />"
enctype="multipart/form-data">
Please select a file to upload : <img src="demo.png" />
<input type="submit" value="upload" />
</form>
Is it possible to do the upload using img tag without using file input tag.
You need to insert your data to form to be able to submit the data to a database or other uses.
Since <img src="demo.png" /> is just a static html code, form canĀ“t get the data from that.
What you can do is to pass the src to <input type="file" name="file" />

Submitting html form with hidded fields using code behind

heloo,
i have a html form which is posting data to a link like
<body onload="javascript:document.E_FORM.submit();">
<form action= method="POST" name="E_FORM">
<input type="hidden" name="a" value="1" size="100"><br />
<input type="hidden" name="b" value="2"><br />
<input type="hidden" name="c" value="3"><br />
</form>
i want to submit this form using code behind using string builder to create form and then submit using WebClient.

asp.net add value to form method

Basically I want to place a url in the form action method.
The ltlUrl.text value is added on the server side in pageLoad.
How do i use the ltlUrl as the action method?
<form action="<%# ltlurl.text%>" enctype="multipart/form-data">
<input type="text" name="title" value="test" />
<input type="file" name="file" />
<input type="submit" />
</form>
Since you are populating the text control on code behind, you can simply do this:
this.Page.Form.Action = "http://someour";
I believe the VB.NET syntax would be:
Me.Page.Form.Action = "http://someurl"

Dynamic HTTP POST instead of form action in asp.net

I have a simple asp.net page where a form action is done, which it takes to the 3d party url and that will return some data as a response. How can I achieve the job done without using static form action.
Below is the form action:
<form name="theForm" method="GET" action="page.aspx" >
<input type="hidden" name="asp" value="hidden values" />
<input type="hidden" name="url" value="http://www.google.com" />
<input type="submit" name="submit" />
</form>
Thanks in Advance.

Resources