Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing aspx login screen to be sent params and work 1

Status
Not open for further replies.

Cooperdam

MIS
Oct 7, 2009
65
US
I have a simple login screen that now has to receive its parameters from another web site. I am not sure what we have to do. The other web site, will get the user id and password. the person there is asking me, does he just redirect user to
this is the codes: First is Login.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="Reports.Login" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " xmlns=" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<table style="width:100%;">
<tr>
<td width="60%">
 </td>
<td width="20%">
 </td>
<td width="20%">
 </td>
</tr>
<tr>
<td>
 </td>
<td style="text-align: right">
 </td>
<td>
<asp:Label ID="lblMessage" runat="server" ForeColor="Red"
style="font-family: Arial, Helvetica, sans-serif; font-size: small"></asp:Label>
</td>
</tr>
<tr>
<td>
 </td>
<td style="text-align: right">
<asp:Label ID="Label1" runat="server"
style="font-family: Arial, Helvetica, sans-serif; font-size: small;"
Text="UserName : "></asp:Label>
</td>
<td>
<asp:TextBox ID="txtUserName" runat="server"
style="font-family: Arial, Helvetica, sans-serif" Text="User"></asp:TextBox>
</td>
</tr>
<tr>
<td>
 </td>
<td style="text-align: right">
<asp:Label ID="Label2" runat="server"
style="text-align: right; font-family: Arial, Helvetica, sans-serif; font-size: small;"
Text="Password : "></asp:Label>
</td>
<td>
<asp:TextBox ID="txtPassword" runat="server"
style="font-family: Arial, Helvetica, sans-serif" Text="test" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td>
 </td>
<td>
 </td>
<td>
<asp:Button ID="btnLogin" runat="server" onclick="btnLogin_Click"
style="font-family: Arial, Helvetica, sans-serif" Text="Login" />
</td>
</tr>
<tr>
<td>
 </td>
<td>
 </td>
<td>
 </td>
</tr>
</table>

</div>
</form>
</body>
</html>

<html



Then there is Login.aspx.cs, basically at the statement response.redirect it will then display the screen we want



using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using System.Data.SqlClient;
using System.Xml;
using Reports.Helpers;

namespace Reports
{
public partial class Login : System.Web.UI.Page
{
const string XML_CONFIG_FILE = "reports.xml";

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ClearSession();
}

// Compilation Directive
// This will by-pass the authentication when DEV flag is added to Conditional Compilation Symbols
// If not, it will ask for login as usual
#if DEV
txtPassword.Text = " ";
btnLogin_Click(null, null);
#endif
}

private void ClearSession()
{
// Clear all Session data
Session.Clear();
}

protected void btnLogin_Click(object sender, EventArgs e)
{
ClearSession();
lblMessage.Text = "";

// Perform Login based on the entered UserName and Password
string sql = "Select * from Users where UserName = '" + txtUserName.Text.Replace("'", "") + "' and Password = '" + txtPassword.Text.Replace("'", "") + "'";
DataSet ds = Lib.GetResults(sql, ConnectionHelper.GetSecurityDatabaseConnection());

if (ds != null)
{
if (ds.Tables.Count > 0)
{
if (ds.Tables[0].Rows.Count == 1)
{

Session["UserName"] = txtUserName.Text.Trim();
Response.Redirect("DashBoard.aspx");



}
else
{
lblMessage.Text = "Invalid UserName/Password.";
}
}
else
{
lblMessage.Text = "Invalid UserName/Password.";
}
}
else
{
lblMessage.Text = "Invalid UserName/Password.";
}

}
}

}
 
Just have their site redirect to your login page. But, I strongly suggest encryping the username and password.
 
OK they want to redirect as you suggested. How do I accept the parameters, first without the encrypt, and then once this works, I will tackle the encrypt part.
 
the thing is, I user the USerid name to get their customers and display them in a combox for use in a Silverlight app.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top