Dynamic IFrame Content from stream - c#

I'm currently trying to implement something called 3d secure into our checkout system-
Implementing DataCash 3DSecure in C#
I've got most of the way there with it, however now, i'm having trouble creating an iFrame with the correct content in.
Basically, the user enters their credit card details, presses the "order" button and the page contacts the payment gateway (DataCash in our case)
If the card requires 3d secure authentication, a pareq (long message) is returned with a bunch of other stuff.
I've generated the page required, using this code:
HttpWebRequest / HttpWebResponse Base 64 problem
However, i need to implement this into an iFrame.
Here's how the documentation suggest doing it, but i cant seem to get it....
<html>
<head>
<title>Please Authenticate</title>
</head>
<body onload="OnLoadEvent();">
<form name="downloadForm" action="https://mybank.com/vbyv/verify" method="POST">
<input type="hidden" name="PaReq" value="AAABBBBCCCCHHHHHH=">
<input type="hidden" name="TermUrl" value="https:// www. MyWidgits.Com/next.cgi">
<input type="hidden" name="MD" value="200304012012a">
</form>
<script language="Javascript"> <!-- function OnLoadEvent() { document.downloadForm.target = "ACSframe"; document.downloadForm.submit(); } //--> </script>
<!-- MERCHANT TO FILL IN THEIR OWN BRANDING HERE -->
<iframe src="blank.htm" name="ACSframe" width="390" height="450" frameborder="0">
</iframe>
<!-- MERCHANT TO FILL IN THEIR OWN BRANDING HERE -->
</body>
</html>

I actually solved this as follows:
http://www.alexjamesbrown.com/blog/development/implementing-datacash-3d-secure-with-asp-net/

Related

Windows 10 UWP Webview local url problems

Windows 10 UWP Webview
I have the two html files located in a www folder under Assets (Assets/www/xxx.html) in a Windows 10 UWP, both files in VS 2015 are set to be copied to the output dir.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Simple Script</title>
</head>
<body>
<form action="submit.html" method="post">
Data:<input type="text" name="somedata" > <br> <br>
<input type="submit" value="Submit" >
</form>
</body>
</html>
and submit.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Dummy Submission</title>
</head>
<body>
<h2> Your data has been submitted - Thank You. </h2>
</body>
</html>
The Webview object is embbeded in the XMAL as below
<WebView x:Name="WebBrowser" HorizontalAlignment="Left" VerticalAlignment="Top" Height="532" Width="1014" NavigationStarting="WebBrowser_NavigationStarting"/>
And the index page is loaded by
/// Helper to perform the navigation in webview
/// </summary>
/// <param name="url"></param>
private void NavigateWebview(string url)
{
try
{
Uri targetUri = new Uri(url);
WebBrowser.Navigate(targetUri);
}
catch (FormatException myE)
{
// Bad address
WebBrowser.NavigateToString(String.Format("<h1>Address is invalid, try again. Details --> {0}.</h1>", myE.Message));
}
}
NavigateWebview(#"ms-appx-web:///Assets/www/index.html");
The page loads and displays correctly but it will not display the linked 'submit.html' page, its just blank.
If I trap the Navigation event it does occur but appears to be prefixed by a GUID as show below.
I have changed paths to absolute etc and read the docs in detail but I fail to see why this does not work.
Ideas Please Guys ...
If I trap the Navigation event it does occur but appears to be prefixed by a GUID as show below
The "GUID" is the package name of current app, it is the default value of Authority part of URI schemes. So if you only want to navigate to another page, this absolutely path is right. You can test by code NavigateWebview(#"ms-appx-web://{your package name}/Assets//www/submit.html");
The page loads and displays correctly but it will not display the linked 'submit.html' page, its just blank
For your issue, I change the form method to get, it will work.
<form action="submit.html" method="get" id="myform">
Data:<input type="text" name="somedata"> <br> <br>
<input type="submit" value="Submit">
</form>
Please Click Me to jump
form has two methods for submiting the form data. Get sends form data via a URL string, post sends form data via the server. In my opinion, post method post data firstly and then navigate, and the data are handled at server side. I haven't seen posted form data received and handled on a HTML page, so I guess you did not need use post method. For get method you can receive data and deal them in javascript, here is how to do.

Html Amp Post shows the current page url?

The Html Amp Post goes to the current url?.
<!doctype html>
<html ⚡>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-form" rc="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
</head>
<body>
<form class="-amp-form" method="post" target="_top" novalidate="" action-xhr="/Home/About">
<input name="name" class="data-input" required="" type="text" placeholder="Name...">
<input name="email" class="data-input" required="" type="email" placeholder="Email...">
<input class="button button-primary" type="submit" value="Subscribe">
</form>
</body>
</html>
Hovering over the submit input button in a browser shows the current url and clicking the button appears to do nothing (using httpFiddler there is no post or get request occuring). The solution is a standard MVC 5 application with the layout changed to include the amp ⚡ symbol in Html declaration and scripts included. Any ideas why it would show the current url when hovering over the button for example https://localhost:44331/Home/Index and not make any posts with the above code when the form button is clicked?
here is one of the resources i have been following from: https://ampbyexample.com/components/amp-form/
The post was working, it just wasn't redirecting to the view after posting. The browser uses the 'action' property on the form to show the url that the user will be sent to and as this value is omitted for an amp action-xhr post it was just showing the current url; however it was still posting to the correct url when clicked. What i was looking to do is a post and redirect and it seems that currently only Get amp requests support page redirection. This might change in the future but for now it needs to use Get requests for page redirecting.

How to send a request to a POST URL from asp.net mvc app

This is my first question to stackoverflow and I have been struggling with it for the past 2 days. I am working on asp.net mvc application and I m pretty new to it. I have a web app and now we are asked to add payment functionality to this app. from the service provider I got the url and they said its a post url and string format to send something like this.
Field1*45005L00|FName*Jonathan|LName*Barley|AmtDue*1570|
Post URL : https://www.sendpayments.com/Client/SSO/Home
the url is like this. So I m not sure how I need to proceed, so what i did was I did some research and found some code for sending a httpwebrequest. so I added a action method and added a form post action to the make payment button, which when clicked would go to the controller and invokes this sendrequest post method (the code I got from internet) however what happens is after I click on my button the code gets executed and I see a blank page with the following line on it. So not sure what is happening. The code is given here..do I need to do this from server or use jquery I m not sure at all. Please help.
System.Net.HttpWebResponse
public HttpWebResponse SendPostRequest(string data, string url)
{
data = "Field1*45005L00|FName*Jonathan|LName*Barley|AmtDue*1570|";
url = https://www.sendpayments.com/Client/SSO/Home;
//Data parameter Example
//string data = "name=" + value
HttpWebRequest httpRequest = (HttpWebRequest) HttpWebRequest.Create(url);
httpRequest.Method = "POST";
httpRequest.ContentType = "application/x-www-form-urlencoded";
httpRequest.ContentLength = data.Length;
var streamWriter = new StreamWriter(httpRequest.GetRequestStream());
streamWriter.Write(data);
streamWriter.Close();
return (HttpWebResponse) httpRequest.GetResponse();
}
Text Recieved
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head><title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function BrowseBack() {
if (window.opener != undefined) {
window.close();
return;
}
history.back();
}
</script>
<link id="idStyleLink" rel="stylesheet" type="text/css" /><link runat="server" rel="icon1" href="images/favicon-med.ico" type="image/ico"/> <link runat="server" rel="icon" href="images/favicon-med.ico" type="image/x-icon"/><title>
</title></head>
<body class="td">
<form method="post" action="./error.aspx?aspxerrorpath=%2fCustomer%2fSingleSignOn%2fIndex" id="form1" autocomplete="off">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="1Rqce+RHGBAZPZKT4DCc7DjqgZIT89HQWlkNktl6sFzFbIvRvk1K/vcj1stkpDLFOCoCvo592mkFaJxGRVVR1Zacgtig9wQ5jOf0qkhv+zLw21ilQ4Grn0Y5mwp7OB+L59sLd/pRxCuqSCSKL23yD/9qIQPMfi0uf5CSCZjROpNEVkzBqOjRFD5WmgGU9gfC9x/xQZ0Yg+fNWua8EuFz7YIC1xVh5cZVX/wPP2wW4iuvTjZ+vvOS20qW3jvCvfjHMusdkgz2biY0wIbWbe3wOgUmHNHAKBEXC4nLincjvtcDbmcLTDcd7xePRd339YZb6Oz8MI2IBc5sZxZs3KENbSeo8IhokTmu5AUWsC+whXuIzJ1NPGiIOBehJNo3kSj847ZvYznsZJvZmvzZN7Kt3OHC0po=" />
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="AB827D4F" />
<input type="hidden" name="__VIEWSTATEENCRYPTED" id="__VIEWSTATEENCRYPTED" value="" />
<div id="Divdefaultmsg">
<b>We are sorry for this inconvenience but we are temporarily experiencing technical difficulties, if the problem persists, please contact Merchant Support at 877-981-3478.<br/>
</b>
</div>
<div>
<span id="Label1"></span>
<span id="lblerror"></span>
</div>
<br /> <div>
<a id="browseback" href="javascript:BrowseBack();">Back</a></div>
</form>
</body>
</html>
Update
Its a CashPro Biller Gateways Standard Single Sign On
Try changing the httpRequest.ContentType to "text/plain", or "text/plain; charset=UTF-8".
"application/x-www-form-urlencoded" is used for sending key-value pairs, so the server might be trying to interpret the data as such.
If that doesn't work try using the Postman Chrome plugin to experiment with sending data to the API. Try different combinations of inputs under the 'Body' tab until you find something that works. That should help you choose the correct ContentType.
The trailing | symbol in the data could also potentially be causing a type conversion issue on the server side too, but it's really hard to tell without more specific error info.

Get Image data from POST request

I have an HTML file
<HTML>
<BODY>
<FORM name="form1" method="post">
<INPUT type = FILE name="image" action = http://localhost:61189/api/Utility" REQUIRED/>
<INPUT type = SUBMIT />
</FORM>
</BODY>
</HTML>
When Submitted it triggers the POST function of the APIController.
I want to get the image data to work on. Where in the Request can i get the image data ?
Well i found a way of entering data into HTML request using multi-part form request.
And C# provides good api to deal with such data.

Dynamically Setting the Src Attribute of an Iframe while maintaining Cross-Browser Compatibility

I am going to create a Iframe which must update its contents dynamically (through the src attribute - The Iframe will change its location every time a different button is clicked) to play different youtube videos that my company has created. The problem is that I saw that you can use jquery to achieve this. I am oblivious to jquery at the moment, but will take time to learn it. For now, I need an answer. How do I use Jquery (or any alternative browser friendly method ) to Change the src Attribute of my Iframe?
<script runat="server">
</script>
<div style="margin-left:auto;margin-right:auto">
<table style="width: 960px" cellpadding="0px" cellspacing="0px">
<tr>
<td rowspan="6">
<iframe title="YouTube video player" width="480" height="390" src="http://www.youtube.com/embed/JZOxqVl5oP4"
frameborder="0" allowfullscreen id="VideoPlayer"></iframe>
</td>
<td style="Width: 130px">
<img width="130px" src="./Images/Video_Logos/l_absa.gif" />
</td>
...
Note that there are 10 buttons. The buttons are images, and I was planning to call different "Methods" for different videos to play.
I know about javascript's Document.GetElementById("VideoPlayer").SetAttribute("src","NEW LOCATION") within a function, but , lets face it. IE6 + 7 sucks.
Just use a link. No need to mess around with JavaScript.
You will need to give the frame a name, that is how links target frames.
<a href="http://youtube.com/etc/etc"
target="name_of_frame">
<img width="130"
src="./Images/Video_Logos/l_absa.gif"
alt="something" />
</a>
The width attribute takes an integer value (or an integer followed by a % character), not a CSS length. Get rid of the px.
The alt attribute on <img> elements is mandatory (even in HTML 5)
From the answer given in:
How do I dynamically change the content in an iframe using jquery?
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script>
$(document).ready(function(){
var locations = ["http://webPage1.com", "http://webPage2.com"];
var iframe = $('#frame');
$(iframe).attr('src', locations[1]);
});
</script>
</head>
<body>
<iframe id="frame"></iframe>
</body>
</html>
I would recommend not using an iFrame to play the YouTube, take a look at the Javascript Youtube API:
http://code.google.com/apis/youtube/js_api_reference.html

Categories