Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-07-30
5
Medium Priority
?
382 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

721 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