virtual directory not being configured as an application error in asp.net app

  • Thread starter Thread starter Tim Zych
  • Start date Start date
T

Tim Zych

Does anybody know what's wrong with this authentication?

I'm following the book ASP.Net Kick Start's advice....

1) Create a new ASP.Net app

2) Create a web.config file in the root directory with the following:
<configuration>
<system.web>
<authentication mode="Forms" />
</system.web>
</configuration>

3) Create a folder called "Secret Files" and in it add a WebForm called
Secret.aspx and another Web.Config file.
The web.config file contains:
<configuration>
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</configuration>

and the Secret.aspx file has a label indicating success if we are redirected
to that page.

4) Add a page called Login.aspx that contains a 2 textboxes (txtUsername and
txtPassword) and a button.

The button_click event has the following code:

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
If txtUsername.Text = "tim" And txtPassword.Text = "password" Then
System.Web.Security.FormsAuthentication. _
RedirectFromLoginPage(txtPassword.Text, False)
Else
Label1.Text = "Invalid Username/Password"
End If
End Sub


When I run this *inside* Visual Studio, it seems to work OK. But when I
replicate this into another asp.net folder, I get the error:
----------------------------------------------------------------------------
Parser Error Message: It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This error
can be caused by a virtual directory not being configured as an application
in IIS.
----------------------------------------------------------------------------

Apparently the framework doesn't like the web.config file in the root
directory.
<authentication mode="Forms" /> is highlighted in the error message.

How can I fix this?

Thanks.
 
What asp.net folder does mean? If it is a simple folder in wwwroot
directory, you should "convert" it into web application. Open IIS manager,
find your folder, right-click -"Properties"->"Create" button.

Dmitri Demyanik, MCP
AITOC, Inc - ecommerce solution provider and web development company
www.aitoc.com
 
Dimitry,

I have the same problem, but when i set the sub folder as virtual
application, the page could not load type 'myproject.mypage' in the <%
.... inherits="..."%> !
Do you have solution ?

thanks and happy christmas.
jean claude
 
Jean,

You can not just copied the source file (.aspx, .vb, .cs)
to the folder, if the component you try to build using the
code behind techniques.

In this approach, you should also copy the binary/dll that
was built in another application, and then paste it /bin
to the target application folder you want.

This is not needed if you write the codes within .aspx
file.

Hope this helps :)

Regards,


Jody Ananda
MCAD.NET,MCSD.NET
"All programs are poems, it just not all programmer are
poets."


-----Original Message-----
Dimitry,

I have the same problem, but when i set the sub folder as virtual
application, the page could not load
type 'myproject.mypage' in the <%
 
Thanks.

Dmitri Demyanik said:
What asp.net folder does mean? If it is a simple folder in wwwroot
directory, you should "convert" it into web application. Open IIS manager,
find your folder, right-click -"Properties"->"Create" button.

Dmitri Demyanik, MCP
AITOC, Inc - ecommerce solution provider and web development company
www.aitoc.com
 
Back
Top