Login Control Issue - asp.net

I'm a junior in a software engineering and web development class and have ran into a problem. I need a log in page so that after a user clicks the log in button, they will be sent to my actual web page. However, every time I click the log in button I recieve this error:
Server Error in '/Case04' Application.
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster."
For this specific project, i am not concerned what the user enters as long as they enter information. I just need it so when the log in button is clicked i am sent to my actual web page which is pc.aspx.
Here is my Code:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>
<!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 id="Head1" runat="server">
<link href="login.css" rel="stylesheet" type="text/css" />
<title></title>
</head>
<body>
<%--Heading--%>
<form name="c_order" id="c_order" runat="server"
action="pc.aspx" method="get">
<table>
<tr>
<td>
<img src="mclogog.jpg" alt="heading" id="heading" />
</td>
</tr>
</table>
<%--login--%>
<asp:Login ID="login" class="login" runat="server" size="10" maxlength="25" EventValidation="false"></asp:Login>
<p id="member" >Already a member?</p>
<%--fieldset for new user --%>
<fieldset>
<legend id="bill">Shipping Information</legend>
<label for="fname" >First Name<span>*</span></label>
<input type="text" name="fname" id="fname" size="27" />
<label for="lname"> Last Name<span>*</span></label>
<input type="text" name="lname" id="lname" size="27" />
<label for="address1">Address #1<span>*</span></label>
<input type="text" name="address1" id="address1" size="57" />
<label for="address2">Address #2</label>
<input type="text" name="address2" id="address2" size="57" />
<label for="city">City<span>*</span></label></td>
<input type="text" name="city" id="city" size="40" />
<label for="state">State<span>*</span> </label>
<input type="text" name="state" id="state" size="3" />
<label for="zip">ZIP<span>*</span> </label>
<input type="text" name="zip" id="zip" size="10" maxlength="10" />
<label for="country">Country<span>*</span></label>
<input type="text" name="country" id="country" size="40" value="United States" />
<p id="ast">
* = Required field, must be filled in.
</p>
</fieldset>
</form>
</body>
</html>
I would appreciate any help, thanks!

The problem is that your page is not handling its own events. You have your < form > tag set up to post-back its values to another page.
< form ... action="pc.aspx" ... /> but your page is really called login.aspx. So, when this form's content gets posted to pc.aspx, it can't decode the viewstate, because it didn't come from pc.aspx.cs. It came from a different page.
Remove the action attribute from your form tag. Like this:
<form name="c_order" id="c_order" runat="server" method="get">

Related

Ftp using filezilla in asp.net

i have created this file in visual studio 2012 . The first page of survey works completely fine but when it re directs to display its showing '500 internal server error. The project has no compilation error . i am opening this file using filezilla can anyone please help me . its a simple program which fetches the value from survey.asp and displays the value in the next form in a tabular format.
------ survey.asp-----------------------------
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Survey Form</title>
</head>
<body>
<form method="post" action="display.asp">
<br/>
Please Enter Your Age <input type="text" name="first" value="<%=request("Age")%>"/> <br /> <br/>
Please Enter Your Salary $ <input type="text" name="sal" value="<%=request("salary")%>"/> <br /><br/>
What level of Education Have You Completed : <br/>
<input type="radio" name="radiobutton" value="<%=request("education")%>"/> Some High School <br />
<input type="radio" name="radiobutton" value="<%=request("education")%>"/> Completed high School <br />
<input type="radio" name="radiobutton" value="<%=request("education")%>"/>Some College Education <br />
<input type="radio" name="radiobutton" value="<%=request("education")%>"/> Completed a B.S Degree <br />
<input type="radio" name="radiobutton" value="<%=request("education")%>"/> Completed a Master Degree <br /> <br/>
<input type="submit" value="Send Survey" />
</form>
</body>
</html>
----------display.asp---------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
Age = request.form("first")
salary = request.form("sal")
education = request.form("radiobutton").ToString();
if age="" or salary="" or education="" then
%>
<html>
<head><title></title></head>
<body>
You must enter all the info
<form method="post " action="survey.asp">
<input type="hidden" name="age" value="<%=age%>" />
<input type="hidden" name="salary" value="<%=salary%>" />
<input type="hidden" name="education" value="<%=education%>" /> <br/>
<input type="submit" value="Return" />
</form>
</body>
</html>
<%
response.end
end if
%>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Display Name</title>
</head>
<body>
You entered: <br />
<table>
<tr>
<td> <%=age%> </td>
<td> <%=salary%> </td>
<td> <%=education %> </td>
</tr>
</table>
<br />
</body>
</html>
This is classic asp with vbscript, not asp.net with C#. You don't get compilation errors with classic because it isn't compiled, it's interpreted at runtime.
You appear to have put a line of C# in display.asp - if you replace the line
education = request.form("radiobutton").ToString();
with
education = Cstr(request.form("radiobutton"))
This should solve your initial 500 error. Enclosing within Cstr() isn't actually necessary, but it's the VBScript way of converting to a string.
I don't think your radio button group will work as you have coded it. If you're trying to preserve the original submitted value you should do something like this.
<input type="radio" name="radiobutton" value="1" <% If request.form("education") = "1" Then Response.write "checked" End if %> /> Some High School <br />
<input type="radio" name="radiobutton" value="2" <% If request.form("education") = "2" Then Response.write "checked" End if %> /> Completed high School <br />
<input type="radio" name="radiobutton" value="3" <% If request.form("education") = "3" Then Response.write "checked" End if %> />Some College Education <br />
<input type="radio" name="radiobutton" value="4" <% If request.form("education") = "4" Then Response.write "checked" End if %>/> Completed a B.S Degree <br />
<input type="radio" name="radiobutton" value="5" <% If request.form("education") = "5" Then Response.write "checked" End if %>/> Completed a Master Degree <br /> <br/>
I'd suggest that having a second form on a different page isn't the best way to do form validation, better to have the form post to itself and use conditional statements to make error messages appear beside the individual form elements if nothing if they're left empty.
Finally, look at this page - it tells you how to enable useful error messages in Classic ASP.
http://www.chestysoft.com/asp-error-messages.asp

Payment Gateway module in dotnetnuke

I have done an interswitch payment gateway in my regular asp.net webform and asp.net mvc.
But I have a requirement to do the same in dotnetnuke which i know i can through module.
In my pay now pay of my application i have a form to send data across to interswitch webservice the form is below
<form name="form1" action="https://stageserv.interswitchng.com/test_paydirect/pay"
method="post">
<input name="product_id" type="hidden" value="XX" />
<input name="pay_item_id" type="hidden" value="XX" />
<input name="amount" type="hidden" value="XXXXXXX" />
<input name="currency" type="hidden" value="566" />
<input name="site_redirect_url" type="hidden" value="http://abc.com /getresponse”/>
<input name="txn_ref" type="hidden" value=" XXXAFTXXX”" />
<input name="hash" type="hidden" value="BB292DF9268F05CB9CBBC5E0C13CC1B13ACA34DC" />
</form>
I need someone to help me out on how i can implement this in my dotnetnukes module.
I faced a similar problem and asked this question. The accepted answer here is how I ended up doing it.
I just added the input fields to the page and then changed the "Pay" buttons PostBackUrl
This way you don't need to add an additional form to the page, and when the user clicks the button, it will submit those fields, so obviously it will pick up the ones it's looking for.
So in your case it would be:
<%-- other page content before --%>
<input name="product_id" type="hidden" value="XX" />
<input name="pay_item_id" type="hidden" value="XX" />
<input name="amount" type="hidden" value="XXXXXXX" />
<input name="currency" type="hidden" value="566" />
<input name="site_redirect_url" type="hidden" value="http://ipsum.com/getresponse”/>
<input name="txn_ref" type="hidden" value=" XXXAFTXXX”" />
<input name="hash" type="hidden" value="BB292DF9268F05CB9CBBC5E0C13CC1B13ACA34DC" />
<%-- pay button would look like this --%>
<asp:Button ID="btnPayNow" runat="server" PostBackUrl="https://stageserv.interswitchng.com/test_paydirect/pay" Text="Pay Now!" />
<%-- other page content after --%>
Of course if you have multiple payment gateway options you can set the PostBackUrl programatically before you display the form: btnPayNow.PostBackUrl = "http://<url>.com"
If you are posting to another site, not even anything on your site then you don't need a module at all.
With DNN you cannot include another form on your site like that. But you could make that a .html page and include that on your site as an iframe or something like that.
That should post to that other service fine.

Paypal Form Tag issue in asp.net

Hello guys i have gatting issue on loading asp.net
i have using master page for sub pages there is a form tag in materpage i have add a paypal button in sub page which is this in master page form tag is also important
in masterpage <form id="form1" runat="server"></form>
and in sup age
<form id="form2" runat="server" name="Paypal" action="https://www.paypal.com/cgi-bin
/webscr"
method="post">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="business" value="
<%=System.Web.Configuration.WebConfigurationManager.AppSettings["email"] %>
" />
<input type="hidden" name="item_name_1" value="<%=Session["ItemName"].ToString()%>"
/>
<input type="hidden" name="amount_1" value="<%=Session["ItemCost"].ToString() %>"/>
<input type="hidden" name="quantity_1" value="1" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="return" value="<%=Session["returnUrl"].ToString() %>"/>
<input type="hidden" name="lc" value="Stronger" />
<input type="image" src="images/paynow.png" border="0" name="submit" alt="Make
payments with PayPal - it's fast, free and secure!"
style="background: url(images/update-account.png);"/>
</form>
I'm getting bug this with sub page below
Server Error in '/Project' Application.
A page can have only one server-side Form tag.
Description: An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: A page can have only one server-side Form tag.
anybody have a idea how can i use form tag in sub page also.
Please check how many <form> tags are written on your aspx/html page. Make sure you are not using masterpage for this page.
Hi I have found this solution and its work solution is below:
<form name="Paypal" action="https://www.paypal.com/cgi-bin/webscr"
method="post" target="_blank"></form>
<form name="Paypal" action="https://www.paypal.com/cgi-bin/webscr"
method="post">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="business" value="
<%=System.Web.Configuration.WebConfigurationManager.AppSettings["email"] %>
" />
<input type="hidden" name="item_name_1" value="<%=Session["ItemName"].ToString()%>"
/>
<input type="hidden" name="amount_1" value="<%=Session["ItemCost"].ToString() %>"/>
<input type="hidden" name="quantity_1" value="1" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="return" value="<%=Session["returnUrl"].ToString() %>"/>
<input type="hidden" name="lc" value="Stronger" />
<input type="image" src="images/paynow.png" border="0" name="submit" alt="Make
payments with PayPal - it's fast, free and secure!"
style="background: url(images/update-account.png);"/>
</form>
This code is working good as i want.
If you'are under a MasterPage Don't use the form tag as long as you're inside a form, just delete it, delete the hidden input that causes the SUBMIT and, instead, use the following ImageButton:
<asp:ImageButton ID="cmdpay" runat="server" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" Text="" ImageUrl="images/paynow.png" ></asp:ImageButton>
It works

Sending form data to another websites form

I am trying to incorporate a reservation widget within my wordpress install and I have everything working fine except sending the data or it not populating on the other sites form. The site I am trying to send data to is an online reservation software: http://www.directinn.com/demo/
Here is how I am doing my form:
<form name="bookingform" action="http://www.directinn.com/demo" method="get" target="_blank">
<input type="text" name="date1" id="Text1" class="ftxt MyDate three columns" maxlength="10" value="" placeholder="Arrival Date"/>
<input type="text" name="date2" id="Text2" class="ftxt MyDate three columns" maxlength="10" value="" placeholder="Departure Date" />
<input type="submit" name="bookingformsubmit" class="book-now" value="Book Now">
<input type="hidden" name="arrivalDay" value="" />
<input type="hidden" name="arrivalMonth" value="" />
<input type="hidden" name="arrivalYear" value="" />
<input type="hidden" name="departureDay" value="" />
<input type="hidden" name="departureMonth" value="" />
<input type="hidden" name="departureYear" value="" />
<input type="hidden" name="numAdults" value="1" />
Any help would be greatly appreciated ;)
So they are saying if you can iFrame in their Form on your page and if you add the USERNAME for example to the URL, your USERNAME will appear on the invoice. Like this I believe:
http://www.directinn.com/iframefull.html/BOB
I do not think you can make your own form and POST to their page. I see no indication that that is possible from the link you posted of the example.
The code you have will submit a load of Query String data to the receiving site.
The target site may implement some type of cross-site posting prevention which is causing the blockage - or they may ignore your query string parameters entirely.

Trouble getting to PayPal Buy Now Buttons to work on a single page in ASP.NET

I confess I am a noob to asp.net and web forms. I'm having an issue incorporating a few PayPal Buy Now buttons on a single page. Basically, the problem is no matter which "Buy Now" button is clicked, the user is taken to paypal to buy the product represented by the last button on the page.
The code for my first button is something like this...
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="ABC123">
<asp:ImageButton runat="server" id="PPImageButton1" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" ImageUrl="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif"/>
My second button is similar to...
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="ABC456">
<asp:ImageButton runat="server" id="PPImageButton2" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" ImageUrl="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif"/>
How can I make the first button send value ABC123 to the PayPal service instead of ABC456?
Thanks in advance.
The POST content of a button is every input in the FORM tag that surrounds the submit button. So to have each button submit a separate set of hidden fields you need to wrap the button and the desired hidden fields in a separate form:
<form ... >
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="ABC123">
<asp:ImageButton runat="server" id="PPImageButton1" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" ImageUrl="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif"/>
</form>
<form ... >
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="ABC456">
<asp:ImageButton runat="server" id="PPImageButton1" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" ImageUrl="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif"/>
</form>
My noob solution for this was to cut each of the buy-it-now buttons and its associated fields out of the aspx page, and put each set in a separate html page.
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>first button</title>
</head>
<body>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="paypal">
<input type="hidden" value="_s-xclick" name="cmd" /> <input type="hidden" value="???????" name="hosted_button_id" />
<table>
<tbody>
<tr>
<td><input type="hidden" value="Member name" name="on0" />Member name</td>
<td><input maxlength="60" size="30" name="os0" /></td></tr>
<tr>
<td><input type="hidden" value="Membership No. (if known)" name="on1" />Membership No. (if known)</td>
<td><input maxlength="60" size="6" name="os1" /></td></tr></tbody></table>
<input type="image" alt="PayPal - The safer, easier way to pay online." src="https://www.paypal.com/en_GB/i/btn/btn_cart_LG.gif" name="submit" /> <img height="1" alt="" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" border="0"/> </form>
</body>
</html>
In the place in the aspx page where you removed the button and other fields, insert an iframe which points to the html page like this:
<iframe width="600" height="" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="mybuttonpage1.htm"></iframe>
It's not your button that sends the value - it's the form it's in, and/or the code behind it.
Could you:
Post the form code?
Post the code behind for this page?
Here is a solution the the multiple form problem when using PayPal with ASP.NET:
http://www.codersbarn.com/post/2008/03/08/Solution-to-ASPNET-Form-PayPal-Problem.aspx
I discuss several workarounds for the problems of inserting PayPal code into an ASP.NET page, and present a different approach in my article at http://blackbeltcoder.com/Articles/ecommerce/quick-and-dirty-buy-now-buttons-in-asp-net.
In the end, you don't need to use a form because PayPal allows you to use a regular anchor link.
I was able to get it to work by removing all the other button containers from the DOM in jQuery. Add a class to your container, and add a CssClass to the ImageButton, "PayPalImageButtons"
<div>
Buy This First Product Below
</div>
<div class="ManualPurchase PayPalButtons">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="ABC123" />
<asp:ImageButton CssClass="PayPalImageButtons" runat="server" id="PPImageButton1" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" ImageUrl="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif" />
</div>
<div>
Buy This Second Product Below
</div>
<div class="ManualPurchase PayPalButtons">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="ABC456" />
<asp:ImageButton CssClass="PayPalImageButtons" runat="server" id="PPImageButton1" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" ImageUrl="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif" />
</div>
and the jQuery
<script type="text/javascript">
function pageLoad() {
$(".PayPalImageButtons").click(function (e) {
$(this).parent().addClass("keep");
$(".PayPalButtons").not(".keep").remove();
});
}
</script>
My next step is dealing with the removed elements height and maybe a Please Wait dialog while the PayPal page is loaded

Resources