allowDefinition=MachineToApplication and errors switching to VS2008 Express

  • Thread starter Thread starter K Viltersten
  • Start date Start date
K

K Viltersten

We have a project working well today and it's developed
on VS2005. Since we're planing to switch to VS2008 in a
soon future, i've been trying to move the project to
VS2008 Express (Web Developer).

After i've moved over all the files, i run into problems
compiling and running it. Both versions of VS are run on
the same computer (with the sam settings, of course).
Still, when i try to run index.aspx, i get error message
as follows:

Error 95 It is an error to use a section
registered as allowDefinition='MachineToApplication'
beyond application level.

It's also suggested that it might be due to that the
directory isn't configured as an application in the IIS.
What can be done to resolve it?

A guide for moving from VS2005 to VS2008 Express would
be great but i have't found one that is good. Not for
web-projects, anyway.
 
re:
!> when i try to run index.aspx, i get error message as follows:

!> Error 95 It is an error to use a section registered as
!> allowDefinition='MachineToApplication' beyond application level.

There should be no conflicts when running projects based on VS 2005 in VWD 2008,
in reference to the "allowDefinition='MachineToApplication' beyond application level" config.

Both the .Net Framework 2.0 and the .Net Framework 3.5 target the same v2.0.50727
base configuration files, and don't use different machine.config nor web.config files.

Did you convert the project when you first opened it in VWD 2008 ?

re:
!> It's also suggested that it might be due to that the directory isn't
!> configured as an application in the IIS. What can be done to resolve it?

The ASP.NET DEvelopment Server included with VWD creates a root application
when it runs your project, so that shouldn't be the root cause for your error.

I suggest you check the specific setting which is causing the problem in your web.config.

There's not too many of them:

<section name="anonymousIdentification"
<section name="authentication"
<section name="healthMonitoring"
<section name="hostingEnvironment"
<section name="machineKey"
<section name="membership"
<section name="profile"
<section name="roleManager"
<section name="securityPolicy"
<section name="sessionState"
<section name="siteMap"
<section name="trust"
<section name="urlMappings"
<section name="cache"
<section name="outputCache"
<section name="outputCacheSettings"
<section name="sqlCacheDependency"

If you are using any of those, you need to have a virtual directory,
at least, or an application, although as mentioned the dev web server
creates one for you when running your code.

Look for web.config entries which use those sections and test-delete them.
( backup the original web.config so you can restore the original settings...if needed )
....until you find the culprit...and post back your results.

Have you set index.asp as your "Start Page" for your project ?
Try setting it ( select it in the Solution Explorer, right-click and select "Set as Start Page" ).

Also, try setting the project's target to .Net Framework 2.0 in the project's property pages,
instead of the .Net Framework 3.5 ( if you don't need .Net Framework 3.5 features... ),
if you selected targeting the .Net Framework 3.5 when you converted the project.

You can always flip it back if that doesn't do anything.
All that does is change a few entries in web.config.




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
We have a project working well today and it's developed
on VS2005. Since we're planing to switch to VS2008 in a
soon future, i've been trying to move the project to
VS2008 Express (Web Developer).

After i've moved over all the files, i run into problems
compiling and running it. Both versions of VS are run on
the same computer (with the same settings, of course).
Still, when i try to run index.aspx, i get error message
as follows:

Error 95 It is an error to use a section
registered as allowDefinition='MachineToApplication'
beyond application level.

It's also suggested that it might be due to that the
directory isn't configured as an application in the IIS.
What can be done to resolve it?

A guide for moving from VS2005 to VS2008 Express would
be great but i have't found one that is good. Not for
web-projects, anyway.
 
!> when i try to run index.aspx, i get error message as follows:
!> Error 95 It is an error to use a section registered as
!> allowDefinition='MachineToApplication' beyond application level.

Did you convert the project when you first opened it inVWD 2008?

I haven't been asked about any conversions. I simply opened
VWD2008 Express and opened the SLN-file containig the
solution i've been working in VS2005. It just got opened
and the only nag i got was one for converting the line breaks
to Windows format.
re:
!> It's also suggested that it might be due to that the directory isn't
!> configured as an application in the IIS. What can be done to resolve
it?

I suggest you check the specific setting which is causing theproblem in
your web.config.

There's not too many of them:

<section name="anonymousIdentification"
<section name="authentication"
<section name="healthMonitoring"
<section name="hostingEnvironment"
<section name="machineKey"
<section name="membership"
<section name="profile"
<section name="roleManager"
<section name="securityPolicy"
<section name="sessionState"
<section name="siteMap"
<section name="trust"
<section name="urlMappings"
<section name="cache"
<section name="outputCache"
<section name="outputCacheSettings"
<section name="sqlCacheDependency"

As far i could see, there was no "section" tags in my web.config
file. The line i'm directed to when clicking on the error
description says:

<system.web>
<customErrors defaultRedirect="Error.aspx" mode="RemoteOnly"/>
BELOW IS THE LINE
<authentication mode="Forms">
ABOVE IS THE LINE
<forms timeout="10000"/>
</authentication>
<compilation debug="true">
<assemblies>
<add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
</system.web>
 
re:
!> I haven't been asked about any conversions. I simply opened VWD2008 Express
!> and opened the SLN-file containing the solution i've been working in VS2005.
!> It just got opened and the only nag i got was one for converting the line breaks to Windows format.

That's really odd.

Everytime I create a project in VS 2005 and later open
the .sln file with VWD, the conversion wizard runs.

re:
!> As far i could see, there was no "section" tags in my web.config file.

There wouldn't be. Those sections go into the machine.config file.
What I asked you was to check whether you web.config contained references to those objects.

re:
!> The line i'm directed to when clicking on the error description says:

!> <authentication mode="Forms">

Yes, that's the reference to <section name="authentication".

What authentication code do you have in your app ?
Do you have a logon page which requests credentials from your users ?

Here's a complete example to test the authentication capability you seem to be missing:

Could you create a new project in VWD, copy the 3 files
I included in web.zip into the new project and run *default.aspx*
by right-clicking it in the Solution Explorer and selecting "View in Browser" ?

....and then post back the results of your test ?

You should get prompted for authentication.
Use "(e-mail address removed)" for both the username and the password.

You should first be sent to login.aspx and then, after inputting the credentials above,
be redirected to login.aspx where the username "(e-mail address removed)" will be displayed.

In case you can't download zip files, here's the text of the files :

web.config:
-----------------
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<compilation debug="true" strict="false" explicit="true">
</compilation>
<pages>
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
</namespaces>
</pages>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Forms">
<forms loginUrl="login.aspx" name=".ASPXFORMSAUTH">
</forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
<system.codedom>
</system.codedom>
<system.webServer>
</system.webServer>
</configuration>
-----------------------

default.aspx:
------------------
<%@ Page Language="VB" %>
<html>
<head>
<title>Forms Authentication - Default Page</title>
</head>

<script runat="server">
Sub Page_Load(ByVal Src As Object, ByVal e As EventArgs)
Welcome.Text = "Hello, " & Context.User.Identity.Name
End Sub

Sub Signout_Click(ByVal sender As Object, ByVal e As EventArgs)
FormsAuthentication.SignOut()
Response.Redirect("Login.aspx")
End Sub
</script>

<body>
<h3>
Using Forms Authentication</h3>
<asp:Label ID="Welcome" runat="server" />
<form id="Form1" runat="server">
<asp:Button ID="Submit1" OnClick="Signout_Click"
Text="Sign Out" runat="server" /><p>
</form>
</body>
</html>
------------

login.aspx:
-----------------
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Security" %>

<script runat="server">
Sub Logon_Click(ByVal sender As Object, ByVal e As EventArgs)
If ((UserEmail.Text = "(e-mail address removed)") And _
(UserPass.Text = "(e-mail address removed)")) Then
FormsAuthentication.RedirectFromLoginPage _
(UserEmail.Text, Persist.Checked)
Else
Msg.Text = "Invalid credentials. Please try again."
End If
End Sub
</script>

<html>
<head id="Head1" runat="server">
<title>Forms Authentication - Login</title>
</head>
<body>
<form id="form1" runat="server">
<h3>
Logon Page</h3>
<table>
<tr>
<td>
E-mail address:</td>
<td>
<asp:TextBox ID="UserEmail" runat="server" /></td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
ControlToValidate="UserEmail"
Display="Dynamic"
ErrorMessage="Cannot be empty."
runat="server" />
</td>
</tr>
<tr>
<td>
Password:</td>
<td>
<asp:TextBox ID="UserPass" TextMode="Password"
runat="server" />
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
ControlToValidate="UserPass"
ErrorMessage="Cannot be empty."
runat="server" />
</td>
</tr>
<tr>
<td>
Remember me?</td>
<td>
<asp:CheckBox ID="Persist" runat="server" /></td>
</tr>
</table>
<asp:Button ID="Submit1" OnClick="Logon_Click" Text="Log On" runat="server" />
<p>
<asp:Label ID="Msg" ForeColor="red" runat="server" />
</p>
</form>
</body>
</html>
-----------

Running those 2 pages with the web.config will tell you if
the problem is with VWD...or with your authentication code.

Please post back the results of the test, OK ?



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
K Viltersten said:
!> when i try to run index.aspx, i get error message as follows:
!> Error 95 It is an error to use a section registered as
!> allowDefinition='MachineToApplication' beyond application level.

Did you convert the project when you first opened it inVWD 2008?

I haven't been asked about any conversions. I simply opened
VWD2008 Express and opened the SLN-file containig the
solution i've been working in VS2005. It just got opened
and the only nag i got was one for converting the line breaks
to Windows format.
re:
!> It's also suggested that it might be due to that the directory isn't
!> configured as an application in the IIS. What can be done to resolve
it?

I suggest you check the specific setting which is causing theproblem in
your web.config.

There's not too many of them:

<section name="anonymousIdentification"
<section name="authentication"
<section name="healthMonitoring"
<section name="hostingEnvironment"
<section name="machineKey"
<section name="membership"
<section name="profile"
<section name="roleManager"
<section name="securityPolicy"
<section name="sessionState"
<section name="siteMap"
<section name="trust"
<section name="urlMappings"
<section name="cache"
<section name="outputCache"
<section name="outputCacheSettings"
<section name="sqlCacheDependency"

As far i could see, there was no "section" tags in my web.config
file. The line i'm directed to when clicking on the error
description says:

<system.web>
<customErrors defaultRedirect="Error.aspx" mode="RemoteOnly"/>
BELOW IS THE LINE
<authentication mode="Forms">
ABOVE IS THE LINE
<forms timeout="10000"/>
</authentication>
<compilation debug="true">
<assemblies>
<add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
</system.web>
 
What authentication code do you have in your app ?
Do you have a logon page which requests credentialsfrom your users?

Yes, that's what we used.
Here's a complete example to test the authenticationcapability you seem
to be missing:

Could you create a new project in VWD, copy the 3 files
I included in web.zip into the new project and run*default.aspx* by
right-clicking it in the SolutionExplorer and selecting "View in
Browser" ?

When i log in suing my e-mail i get to see the follwing
text piece.

Using Forms Authentication
Hello, (e-mail address removed)

When i log in using other nick/password i get the red
error message as follows.

Invalid credentials. Please try again.
You should get prompted for authentication.
Use "(e-mail address removed)" for both the username and thepassword.

You should first be sent to login.aspx and then, afterinputting the
credentials above, be redirected tologin.aspx where the username
"(e-mail address removed)"will be displayed.

Yes, except that i get sent to default.aspx at the
successful login, not login.apsx. Perhaps that's what
you ment?
Running those 2 pages with the web.config will tell you if
the problem is with VWD...or with your authentication code.
Please post back the results of the test, OK ?

Well, what do you think?
 
re:
!> Yes, except that i get sent to default.aspx at the
!> successful login, not login.apsx. Perhaps that's what you ment?

Yes, that's what I meant.

re:
!> When i log in suing my e-mail i get to see the follwing text piece.
!> Using Forms Authentication
!> Hello, (e-mail address removed)
!> When i log in using other nick/password i get the red error message as follows.
!> Invalid credentials. Please try again.
!> Well, what do you think?

That means that you don't have a problem with whether authentication works or not.

As the example shows, authentication works when you create a new project in VWD
and run it with the development server, even if the project is not marked as an application.

It looks like you have a problem with your application's configuration,
inherited from your old project, especially since you say you did not
convert the project to VWD 2008 ( which you should have been prompted to do ).

What I'd suggest is for you to create a new project in VWD,
and add your old project's files one by one with "Add existing item".

Whatever the problem is with your application's configuration should go away that way.
From then on, you should be able to continue developing the app in the new project.



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 
Back
Top