.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

web.config

Posted By: DPK     Posted Date: August 25, 2008    Points:2   Category :ASP.Net
hi my code is here:
---------------------
<location path ="Administration">
<system.web>
<authentication mode="Forms">
<forms loginUrl="LgPg.aspx" name="history" protection="All" />
</authentication>

<authorization>
<allow users="?"/>
</authorization>
</location>
---------------------
My subdirectory name is = "Administration" and i want authentication in all web pages inside it only, not in my root's directory's pages.
and I am getting this error here:
=========================================
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. D:\IT_Masters\DB\IT\Dot_Net_Programmes\VS 2008\Copy of PAGG\web.config 45
================================================
someone can give me whole IDEA of this error?

THANKS IN ADVANCE...!!

Responses
Author: Pankaj Mishra             
Posted Date: August 25, 2008     Points: 5   

Hi,
Try like this

<authentication mode="Forms">
<forms name="history" path="Administration" loginUrl="LgPg.aspx" protection="All" timeout="30">
</forms>
</authentication>


Hope this will help you

Cheers
Pankaj

Author: DPK             
Posted Date: August 25, 2008     Points: 5   

Hello Friend! thanks for your reply!!

but you did not mention here authorization tag without authorization authentication is nothing...

but now i tried as u said, i tried with both
---------
1st one
===================================================
<authentication mode="Forms">
<forms loginUrl="LoginPage.aspx" path="Administration" name="history" protection="All" />
</authentication>

<authorization>
<allow users="?"/>
</authorization>
====================
2nd one
===================================================
<authentication mode="Forms">
<forms loginUrl="LoginPage.aspx" path="Administration" name="history" protection="All" />
</authentication>
=========================================

but both are not working, I can still open my administration form directly.

Author: Pankaj Mishra             
Posted Date: August 25, 2008     Points: 5   

HI,
you can add Authorization in the next line after authencation...below is the full configuration.

<system.web>
<authentication mode="Forms">
<forms name="history" path="Administration" loginUrl="LgPg.aspx" protection="All" timeout="30">
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>


Hope this will help you

Cheers
Pankaj

Author: DPK             
Posted Date: August 25, 2008     Points: 5   

actually I have done what I wanted to do..but for doing that I had to make two CONFIG file but I want to know that, can it be done by taking only one CONFIG file.
i''ve done as u said but it is opening login page at first and I dont wanna do that I wanna authenticate only in one file that can be open if u click on "Admin" link and only that file shud ask for login..

can i do that in single config file.

Author: Pankaj Mishra             
Posted Date: August 25, 2008     Points: 5   

Hi,
I could see your tag is <allow users="?"/>

it should be

<deny users="?" />

Cheers
Pankaj

Author: Pankaj Mishra             
Posted Date: August 25, 2008     Points: 5   

Hi,
You can have multiple web.config file under each folder you want to restrict.

Hope this will give you an idea

Cheers
Pankaj

Author: Pankaj Mishra             
Posted Date: August 25, 2008     Points: 5   

Hi,
Yes you can do that in one Config file like this.


<system.web>
<authentication mode="Forms">
<forms name="history" path="Administration" loginUrl="LgPg.aspx" protection="All" timeout="30">
<credentials passwordFormat="Clear">
<user name="abc" password="abcPassword" />
<user name="xyz" password="xyzPassword" />
</credentials>
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>


Hope this will help you

Cheers
Pankaj

Author: DPK             
Posted Date: August 25, 2008     Points: 5   

ya friend as i told I have solved my problem by multiple config file but here in forums I just wanted to know that..
Can I restrict my sub directory through single CONFIG file or NOT?

Author: Pankaj Mishra             
Posted Date: August 25, 2008     Points: 5   

Hi,

I dont think you can do that.You have to go with multiple config file for each folder you want to restrict.

Cheers
Pankaj

Author: DPK             
Posted Date: August 25, 2008     Points: 5   

Okk thanks friend for your consecutively replies. :)



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend