Error to use a section registered as allowDefiniti

2019-01-02 18:01发布

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

The top line in all of my aspx pages in my /portal/ directory has this error message, and I know it's a common one. I have googled this error message to no end, and I see a lot of posts telling me to configure the /portal/ folder as an application in IIS (which I have), and more posts telling me I have nested web.configs (but none of the postings offer guidance toward a solution).

My setup is that I have a web.config in my root directory, and then I'm trying to make a company portal, in the /portal/directory. The /portal/ directory has its own (necessary) web.config.

My web.config line 50 is like this:

    <customErrors mode="Off" defaultRedirect="customerrorpage.aspx"/>
    <anonymousIdentification enabled="true"/>
    <authentication mode="Forms"/>
    <membership defaultProvider="MyProvider">

So I have domain.com/web.config AND domain.com/portal/web.config ... so my domain.com/portal/default.aspx page will not load.

What is the real solution to this? Do I somehow find a way to merge my root web.config with my /portal/ directory web.config, or am I way off base here?

Any guidance would be greatly appreciated!

23条回答
看风景的人
2楼-- · 2019-01-02 18:32

As RY4N says above, it's not necessarily the web.config in your Project folder that causes the problem. In some cases I have found that running a build under the Debug profile will leave behind detritus in the Debug folder under the project in question. There is often a web.config file in here that leads to the error above when you subsequently run a build under the Release profile.

The solution that works for me here is to delete the entire Debug folder that the prior build(s) created under the project directory.

查看更多
伤终究还是伤i
3楼-- · 2019-01-02 18:32

I have come up with another possible reason that this occurs.

I had an older web application built in 2.0. I migrated it to a 4.5 solution.

The application built and debugged just fine when inside of Visual Studio, but then when I attempted to Publish the web application, this error occurred over and over.

I finally discovered the problem was that Build Action for the web.config file was "Embedded Resource" rather than "Content". Also, the Copy To Output Directory was set to "Always Copy" rather than "Do not copy". I do not know when these settings were made, but I believe it was back in the 2.0 version of the application.

Modifying the settings for the web.config file allowed the Publish action in Visual Studio 2012 publication to work flawlessly.

查看更多
千与千寻千般痛.
4楼-- · 2019-01-02 18:32

Windows start -> open Sites -> IIS -> right click your site -> Manage Web Site -> Advance Setting -> browse Physical Path -> try to select sub-folder of the once you are selection currently.

the logic is that the web config file inside the subfolder is trying to make changes and this is not permitted, has to be the selected folder : http://scottonwriting.net/sowblog/archive/2010/02/17/163375.aspx

查看更多
皆成旧梦
5楼-- · 2019-01-02 18:34

Delete and create the virtual Directory again. Right Click and Convert the virtual Directory to "Application"

查看更多
看风景的人
6楼-- · 2019-01-02 18:34

It was fine on localhost but when I published a release on the server, I started the same error for few pages. Then I cleaned up the solution and rebuild & published, things got fixed.

查看更多
登录 后发表回答