For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > August 2004 > About Web.config









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author About Web.config
Wang Jie

2004-08-26, 8:57 am

Hi.

I have a web app that uses Forms auth in root Web.config, users must login
to access asp.net resources. Now, I want one of the sub directory can be
accessed anonymously. I found that if I just put a web.config which sets
<authentication mode="None" /> in that sub dir will cause a Configuration
Error ( 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.), but I have no idea how to deal with it.

Anybody can help me out?

Thanks!
Curt_C [MVP]

2004-08-26, 4:07 pm

look at the <location> tag for the web.config. You can set things like
security on a per file, and I believe per folder, basis there.

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com


"Wang Jie" < midnightfrank@THIS_SHOULD_BE_HOTMAIL_DOT
_COM.NoSpam> wrote in
message news:EDFE7343-0FFE-4FF0-A96E-1BD53F892CD7@microsoft.com...
> Hi.
>
> I have a web app that uses Forms auth in root Web.config, users must login
> to access asp.net resources. Now, I want one of the sub directory can be
> accessed anonymously. I found that if I just put a web.config which sets
> <authentication mode="None" /> in that sub dir will cause a Configuration
> Error ( 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.), but I have no idea how to deal with it.
>
> Anybody can help me out?
>
> Thanks!



Juan Romero

2004-08-26, 4:07 pm

This a simple problem with a simple solution. Your approach is right. You
need to put another config file there, the problem is that this config file
needs and APPLICATION!, lol, so just go to IIS, select the subfolder in
question (the one holding the config file), right click, properties,
Directory tab. There is a section in the bottom called "Application
Settings". Let me guess, "Application Name" is grayed out?... he he, Click
the create button and that's it!
Apply the changes, go back and recompile your project (just to make sure).
It should display fine now.

Good luck!

"Wang Jie" < midnightfrank@THIS_SHOULD_BE_HOTMAIL_DOT
_COM.NoSpam> wrote in
message news:EDFE7343-0FFE-4FF0-A96E-1BD53F892CD7@microsoft.com...
> Hi.
>
> I have a web app that uses Forms auth in root Web.config, users must login
> to access asp.net resources. Now, I want one of the sub directory can be
> accessed anonymously. I found that if I just put a web.config which sets
> <authentication mode="None" /> in that sub dir will cause a Configuration
> Error ( 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.), but I have no idea how to deal with it.
>
> Anybody can help me out?
>
> Thanks!



Ben Lovell

2004-08-26, 8:58 pm

The simple thing to do (without having to create a seperate virtual
directory or application) is to add a web.config file to the directory you
wish to allow anonymous to, with the following content:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</configuration>


--
Ben
http://bitarray.co.uk/ben




"Juan Romero" <juan.romero@bowne.com> wrote in message
news:OBMd$13iEHA.644@tk2msftngp13.phx.gbl...
> This a simple problem with a simple solution. Your approach is right. You
> need to put another config file there, the problem is that this config
> file
> needs and APPLICATION!, lol, so just go to IIS, select the subfolder in
> question (the one holding the config file), right click, properties,
> Directory tab. There is a section in the bottom called "Application
> Settings". Let me guess, "Application Name" is grayed out?... he he, Click
> the create button and that's it!
> Apply the changes, go back and recompile your project (just to make sure).
> It should display fine now.
>
> Good luck!
>
> "Wang Jie" < midnightfrank@THIS_SHOULD_BE_HOTMAIL_DOT
_COM.NoSpam> wrote in
> message news:EDFE7343-0FFE-4FF0-A96E-1BD53F892CD7@microsoft.com...
> error
> application
>
>



Wang Jie

2004-08-27, 3:57 am

Thank you for the tip. It works.

"Curt_C [MVP]" wrote:

> look at the <location> tag for the web.config. You can set things like
> security on a per file, and I believe per folder, basis there.
>
> --
> Curt Christianson
> Owner/Lead Developer, DF-Software
> Site: http://www.Darkfalz.com
> Blog: http://blog.Darkfalz.com
>
>
> "Wang Jie" < midnightfrank@THIS_SHOULD_BE_HOTMAIL_DOT
_COM.NoSpam> wrote in
> message news:EDFE7343-0FFE-4FF0-A96E-1BD53F892CD7@microsoft.com...
>
>
>

Wang Jie

2004-08-27, 3:57 am

Yes, it works. Now I've found why I was wrong yesterday. I shouldn't put a
<authentication /> section in the sub dir's web.config. That's why the
ASP.NET throws an exception.

"Ben Lovell" wrote:

> The simple thing to do (without having to create a seperate virtual
> directory or application) is to add a web.config file to the directory you
> wish to allow anonymous to, with the following content:
>
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
> <system.web>
> <authorization>
> <allow users="*" />
> </authorization>
> </system.web>
> </configuration>
>
>
> --
> Ben
> http://bitarray.co.uk/ben
>
>
>
>
> "Juan Romero" <juan.romero@bowne.com> wrote in message
> news:OBMd$13iEHA.644@tk2msftngp13.phx.gbl...
>
>
>

Frank Mamone

2004-08-31, 3:57 am

That's correct as it inherits the authentication tag of the parent's
web.config. An application can have only one type of authentication. That's
why if you make your sub-directory an application it will work .

However, I think the cleanest way is to use the "location" tag as someone
suggested.

What method did you end up using??

-Frank M.




"Wang Jie" < midnightfrank@THIS_SHOULD_BE_HOTMAIL_DOT
_COM.NoSpam> wrote in
message news:8ED1BBB9-0A88-4A6C-A311-87765DA3B1EB@microsoft.com...[color=darkred]
> Yes, it works. Now I've found why I was wrong yesterday. I shouldn't put a
> <authentication /> section in the sub dir's web.config. That's why the
> ASP.NET throws an exception.
>
> "Ben Lovell" wrote:
>
you[color=darkred]
You[color=darkred]
in[color=darkred]
Click[color=darkred]
sure).[color=darkred]
in[color=darkred]
be[color=darkred]
sets[color=darkred]
Configuration[color=darkred]


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com