cant call the web service from html page - c#

I am trying to call an asp.net web service from an html page,but its not able to call the web service .but instead its open the url for the webservice only..
I tried to call it from the FORM in html on action="web service link and method ="POST":
<form id="getdata" method="post" action="192.168.1.1:85/Service.asmx?op=Hello" target="_blank">
<input id="btnload" type="submit" value="Submit" />
</form>
ERROR ITS SHOWS:
The webpage at 192.168.1.1:85/Service.asmx?op=Hello might be temporarily down or it may have moved permanently to a new web address.
Error code: ERR_INVALID_RESPONSE
Web service is working fine and tested.
pls help.....

Your action="" attribute needs to specify the URI scheme because it isn't a relative URI.
Use this:
action="http://192.168.1.1:85/Service.asmx?op=Hello"
In a URI, the scheme (often incorrectly called "the protocol") is the first part before the colon which states what type of URI it is, for example:
mailto:foo#bar.com
http://hostname:8080/path
file://\\SMBServer\share\path
urn:epc:tag:cpi-var:3.0614141.5PQ7%2FZ43.12345

Related

How do I force a Blazor app to accept POST requests?

I need my app to allow POST requests from anywhere without throwing a 400 Bad Request error. I am using <form action='/anotherurl' method='post'> and need to be able use the parameters passed through POST on another page in my application. Note: I cannot use GET because I do not want the parameters visible in the URL.
I have tried adding #attribute [IgnoreAntiforgeryToken] to the page but that did not work. Is there a way to force Blazor to allow for the POST request to go through?
Edit: Here is the entire form
<form action="/ClientReports" method="post" target="_blank">
#foreach (var id in SelectedClientIds)
{
<input type="hidden" id="Params" name="Params" value="#id">
}
<input type="submit" value="Client Reports">
</form>
The parameters are added to hidden inputs and then submitted like a normal HTML form but when the navigation occurs the result is a 400 error. The same code with a GET request does work.
Adding #attribute [IgnoreAntiforgeryToken] to the _Host.cshtml file will allow HTML forms to POST to a Blazor Server app.
Note: Since Blazor is a SPA this will turn off Anti-forgery globally, more code is required to turn it off for individual pages.

Can the Kestrel receive form-data with an endpoint instead of a controller?

I want to use asp.net core Kestrel to make a simple server receive picture files from the html clients. I use an endpoint instead of a controller to get the target. Some browser have a size limit of posting the large url encoded string so I have to choose form-data rather than url-encoding. But I cannot receive any form-data in the server-side endpoint method:
client side:
<form id="form" action="/api/do" enctype="multipart/form-data" method="post">
<p>
<input type="file" id="file" accept="image/*" />
<input type="submit"/>
</p>
</form>
server side:
//register the endpoint
endpoints.MapPost("/api/do", Do);
.
.
.
async Task Do(HttpContext context)
{
var form = await context.Request.ReadFormAsync();
var file = form.Files[0];
....
}
The length of form.Files is always 0.
Must I use a controller?
Finally, I found what's wrong with the codes, I forgot to give a name of the "input element". If there is no name of the input element the browser will not submit it.

Post HTML form from ColdFusion to asp.net

I am working with a credit card payment gateway. The access to gateway is written in ColdFusion (8). I am developing a new web site in asp.net/C# and using this payment gateway in ColdFusion. I could sucessfully post data from HTML form in my asp.net page to ColdFusion page. After processing the payment the ColdFusion page posts back a form with data to the asp.net page.
<cfoutput>
<form name="frmupdate" method="post" action="#return_url#">
<input type="hidden" name="ordernumber" value="#order_no">
</form>
</cfoutput>
The redirection is done correctly and debug point in asp.net page (return_url) is hit. When I try to access the form field "ordernumber" (Request.Form["ordernumber"]) it always returns null. Cannot change the logic in ColdFusion. Please give me a hint to make this work. Or any basic rule I have forgotten?
The complete code should be:
<cfoutput>
<form name="frmupdate" method="post" action="#return_url#">
<input type="hidden" name="ordernumber" value="#order_no#">
</form>
</cfoutput>

Umbraco 4.11.3 : Client side form upload (multipart/form-data) gives 404

I'm using umbraco with extensionless urls.
I've inserted a simple piece of HTML in one of my masterpages (en/test) :
<form method="post" enctype="multipart/form-data">
<input type="submit" />
</form>
When I press the submit button, I get a 404. The path is exactly the same and should exist.
When I remove the enctype part, the submit occurs fine.
I can't figure out how to fix this, but I bet it has something to do with the rewriting.
I also tried the following without success:
<form method="post" enctype="multipart/form-data" action="/en/test">
<input type="submit" />
</form>
<form method="post" enctype="multipart/form-data" action="/en/test.aspx">
<input type="submit" />
</form>
The only page where I CAN use the enctype attribute, is on the actual homepage. I guess this has to do with the fact that the physic default.aspx exists.
=============== UPDATE =================
There is only one form element in the page, the one that I've inserted. So a "whole page" form element is certainly not the case. Secondly, yes the form is in theory posting back to itself. I also tried an empty action tag, plus an action tag with the full url as suggested, with the same results.
When I either use the following scenario's:
No action attribute
action=""
action="{relative path}"
action="{absolute path}"
I end up on exact same URL as where I fired the submit from. But it's a 404. When I press the enter key in my address bar, no 404, I'm back at my original page with the same URL.
First question I should ask is do you get a 404 when you browse to "/en/test" or "/en/test.aspx". For the form to post back to itself try an empty action e.g. action="" or writing the current url into the action attribute. And one further question, do you have another form wrapped around your page with the runat="server" attribute because if you have you will end up with nested forms which will also cause you issues.
On a side node I would strongly suggest upgrading your installation to at least v4.11.4 due to a bug that was introduced in 4.10. Please see the following for details...
Trying to publish a root node (parent) after unpublishing a child result in a YSOD:
http://issues.umbraco.org/issue/U4-1491
Path Fixup
http://our.umbraco.org/projects/developer-tools/path-fixup

post a <FORM> to sharepoint page

I am doing following in one of my webpart .ascx file.
<FORM action="https://illustration.sagicorlifeusa.com/fse5/main/FormPost.aspx" id="frmLogin" method="post" target=blank>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<%= CompleteRequest %>
<input type="submit" name="__exclude__Submit" value="Run Sagicor Life Illustration Software Online" />
Notice the method="post"; However, looks like when I add this web-part, The hosting page already has a <FORM/> . How can I do the above POST?
posting to a new window from inside an ASPX web form (which SharePoint is) is tricky, because the framework wraps everything in a <form> it keeps track of. If you are required to post to the target page (i.e. get isn't good enough), you might have to:
create a separate .aspx page entirely to produce the form
open that form from within your Web Part with a JS call to window.open or an <a href="..." target="blank"
auto-post that form, with JavaScript, as soon as it loads.
(I have no firsthand experience with sharepoint; take this answer with a grain of salt.)

Categories