Solved

Delphi 8 ASP.NET Forms Authentication problem - "Server Application Unavailable "

Posted on 2004-07-30
5
379 Views
Last Modified: 2010-04-05
I am having difficulties using form authentication in my Delphi 8 ASP.NET application.

To test, I created a small project with two forms, WebForm1.aspx and Login.aspx in a new virtual directory under IIS on my Win 2KPro machine.  Both forms display fine using the "Run without debugging" option without authentication.

The problem arises when I add these lines to the web.config file:

  <authentication mode="Forms">
      <forms name="AuthTestCookie" loginUrl="login.aspx" protection="All" path="/" />
  </authentication>

  <authorization>
       <deny users="?" />
   </authorization>

With these additions, I often get a "Server Application Unavailble" error, but not always.  This is usually followed by a inetinfo.exe - Application Error popup (trying to read memory at 0x0000004).  

Sometimes, it will take me to the Login page, only to give the error after clicking the Login button.  The login form is simply a blank form with a button.  The event handler looks like this, for simplicity:

   procedure TLogin.Button1_Click(sender: System.Object; e: System.EventArgs);
   begin
     FormsAuthentication.RedirectFromLoginPage('TestUser',False);
   end;

WebForm1.aspx contains one line of text, "Hello World!!!".
  <form runat="server">Hello World!!!  </form>


Sometimes it works. Mostly, it doesn't.

I tested the application using Alt+RD, 'Run without Debugging' from Delphi 8. (The start page is set to WebForm1.aspx.)  
I've also tested directly from my browser -> http://localhost/AuthTest/WebForm1.aspx

I am using IIS, not Cassini.  

I can remove the "Deny Users" line from the web.config and both pages load ok.
IIS is set to allow aynonomous users.
I've tried   <deny users="*" />    as well.
I have run the command:
c:\winNT\microsoft.net\framework\v1.1.4322\aspnet_regiis.exe -i

Any ideas?
0
Comment
Question by:roknjohn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 1

Author Comment

by:roknjohn
ID: 11682379
This may be related...

 It doesn't look like my session objects are working either. On a form with one label (eName) and two buttons, I coded these events:

procedure TDefaultForm.Page_Load(sender: System.Object; e: System.EventArgs);
begin
  if Session['UserName']<>nil then
    eName.Text := Session['UserName'].ToString;
end;

procedure TDefaultForm.Button2_Click(sender: System.Object; e: System.EventArgs);
begin
  Session['UserName'] := 'John';
end;

procedure TDefaultForm.Button1_Click(sender: System.Object; e: System.EventArgs);
begin
  Session['UserName'] := 'Paul';
end;

I thought that by clicking the buttons, the label would change to John or Paul.  
The label stays blank.  What gives?
0
 
LVL 1

Author Comment

by:roknjohn
ID: 11684572
I am still having this problem with authentication and session variables.  I suspect that the authentication problem is related to the more basic problem of the session variables not persisting.

Here what I've done:
I installed Update 2 from Borland.
I set my IE browser to 'Accept All Cookies'. (It was set to 'Low').
I created a new ASP.NET application, using all default names. (WebApplication1,etc.)
I added 3 labels and 2 buttons to WebForm1.
Here is the code that I added:

procedure TWebForm1.Page_Load(sender: System.Object; e: System.EventArgs);
begin
  Label1.Text := 'Session Id = '+Session.SessionID;
  if Session['MyVar']<>nil then
    Label2.Text := 'MyVar = '+Session['MyVar'].ToString
  else
    Label2.Text := 'MyVar is undefined.';
end;

procedure TWebForm1.Button1_Click(sender: System.Object; e: System.EventArgs);
begin
  Session['MyVar'] := 'George Bush';
  Label3.Text := 'MyVar set to '+ Session['MyVar'].ToString;
end;

procedure TWebForm1.Button2_Click(sender: System.Object; e: System.EventArgs);
begin
  Session['MyVar'] := 'John Kerry';
  Label3.Text := 'MyVar set to '+ Session['MyVar'].ToString;
end;

Each time that the page is loaded, the SessionID stays the same, as expected, but the MyVar object is undefined.  When I click one of the buttons, Label3 correctly shows the new value, but Label2 always shows as undefined.

Here is the output:

First Display:
   Session Id = bjhiwo2fgvpsgcrxxsxqk245
   MyVar is undefined.
   Label  

After clicking Button1:
  Session Id = bjhiwo2fgvpsgcrxxsxqk245
  MyVar is undefined.
  MyVar set to George Bush  

After clicking Button2:
  Session Id = bjhiwo2fgvpsgcrxxsxqk245
  MyVar is undefined.
  MyVar set to John Kerry  

0
 
LVL 1

Author Comment

by:roknjohn
ID: 11685686
Problem solved.

I re-installed IIS (after removing it) then ran the aspnet_regiis.exe -i utility.  All works well now.  

Two days shot to heck!  
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 13361151
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month8 days, 2 hours left to enroll

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question