I have a simple webpage that I want to protect with a username and password. I dont need to use information stored in a database as there will only ever be one username so Ive put it in the web.config file. Heres an example of my settings. (I dont need a login page either as i just deny access)
<authentication mode = "Forms"><forms loginUrl="NotAllowed.aspx" protection="All" timeout="90"><credentials passwordFormat = "Clear"><user name ="abc" password = "123"/></credentials></forms></authentication><authorization><deny users = "?"/></authorization>
I basically want to put the username and password in the URL as such
http://mywebsite/default.aspx?u=abc&p=123
I know this is not the most secure method (far from it) but its only meant for denial of any attempted aunauthorised opportuinistic access by typing in the url.
I then have this in my code behind
protected void Page_Load(object sender, EventArgs e){
if (FormsAuthentication.Authenticate(Request.QueryString["u"],Request.QueryString["p"])){
FormsAuthentication.RedirectFromLoginPage(Request.QueryString["u"], false);}
else
{
Response.Redirect("NotAllowed.aspx");}
TextBoxUsername.Focus();
if (!IsPostBack){
TextBoxDate.Text = DateTime.Now.ToLongDateString() + " : " + DateTime.Now.ToLongTimeString();}
}
this doesnt seem to be working though, can anyone give me some pointers ?
tia.. mark.