Monday, March 26, 2012

web.config problem

i have

<authorization>

<deny users="?"/>

<allow roles="Admin"/>

</authorization>

in my web.config file, its blocking pages that the annonomous user should be able to see like the register.aspx page..., any way to fix this...

hi,

suppose u a have a webpage say"Example.aspx " whcich can be viewed by everyone to do this write the following Code in the webconfig file


<location path="Example.aspx">
<system.web>
<authorization>
<allow users="*"/>
<allow users="?"/>

</authorization>
</system.web>
</location>

this should be written inside the

<configuration>

</configuration>

Hope this will help u..

Plz mark it as answer if u find this useful

NB: this might be useful to u

suppose there is a folder say "client" in the root of the project which contains webpages that all internet users can see. then instead adding each page as mentioned above u can add in the way given below

<location path="client">
<system.web>
<authorization>
<allow users="*"/>
<allow users="?"/>
</authorization>
</system.web>
</location>


when i use this the site does not work at all:

 "register.aspx">"true"/>"?"/> "*"/> "?"/>"Admin"/>"Gender" type="string"/>"FirstName" type="string"/>"LastName" type="string"/>"BusinessName" type="string"/>"BusinessPhone" type="string"/>"BusinessURL" type="string"/>"MobileNumber" type="string"/>"MobileCarrier" type="string"/>"State" type="string"/>"City" type="string"/>"Zipcode" type="string"/>"AccountType" type="string"/>"ComName" type="string"/>"ComAddress" type="string"/>"realFM_Name" type="string"/>"realFM_PhoneNumber" type="string"/>"realFM_Address" type="string"/>"realFM_frequency" type="string"/>"realFM_Dial" type="string"/> "ResellerAccountType" type="string"/>"Forms"/>"AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="2" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/"/>"asp"namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>"System.Web.UI.WebControls.CompareValidator" mappedTagType="System.Web.UI.Compatibility.CompareValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>"System.Web.UI.WebControls.CustomValidator" mappedTagType="System.Web.UI.Compatibility.CustomValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>"System.Web.UI.WebControls.RangeValidator" mappedTagType="System.Web.UI.Compatibility.RangeValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>"System.Web.UI.WebControls.RegularExpressionValidator" mappedTagType="System.Web.UI.Compatibility.RegularExpressionValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>"System.Web.UI.WebControls.RequiredFieldValidator" mappedTagType="System.Web.UI.Compatibility.RequiredFieldValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>"System.Web.UI.WebControls.ValidationSummary" mappedTagType="System.Web.UI.Compatibility.ValidationSummary, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>-->"true" to insert debugging symbols into the compiled page. Becausethis affects performance,set this value totrue only during development. -->"true">"System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>"System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>"System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>"System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>"*" path="*.asmx"/>"*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>"GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>"ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>"Off"/>

<location path="register.aspx">
<system.web>
<roleManager enabled="true"/>
<authorization>
<deny users="?"/>
<allow users="*"/>
<allow userd="?"/>
<allow roles="Admin"/>
</authorization>
<profile>
<properties>
<add name="Gender" type="string"/>
<add name="FirstName" type="string"/>
<add name="LastName" type="string"/>
<add name="BusinessName" type="string"/>
<add name="BusinessPhone" type="string"/>
<add name="BusinessURL" type="string"/>
<add name="MobileNumber" type="string"/>
<add name="MobileCarrier" type="string"/>
<add name="State" type="string"/>
<add name="City" type="string"/>
<add name="Zipcode" type="string"/>
<add name="AccountType" type="string"/>
<add name="ComName" type="string"/>
<add name="ComAddress" type="string"/>
<add name="realFM_Name" type="string"/>
<add name="realFM_PhoneNumber" type="string"/>
<add name="realFM_Address" type="string"/>
<add name="realFM_frequency" type="string"/>
<add name="realFM_Dial" type="string"/>
<add name="ResellerAccountType" type="string"/>
</properties>
</profile>
<authentication mode="Forms"/>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="2" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/"/>
</providers>
</membership>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
<!--<tagMapping>
<add tagType="System.Web.UI.WebControls.CompareValidator" mappedTagType="System.Web.UI.Compatibility.CompareValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.CustomValidator" mappedTagType="System.Web.UI.Compatibility.CustomValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RangeValidator" mappedTagType="System.Web.UI.Compatibility.RangeValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RegularExpressionValidator" mappedTagType="System.Web.UI.Compatibility.RegularExpressionValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RequiredFieldValidator" mappedTagType="System.Web.UI.Compatibility.RequiredFieldValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.ValidationSummary" mappedTagType="System.Web.UI.Compatibility.ValidationSummary, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</tagMapping>-->
</pages>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></assemblies>
</compilation>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
<customErrors mode="Off"/>
</system.web>
</location>

I have a suggestion. Place all the secured pages in a sub directory, say Protected, in your root directory. Include a seperate web.config file for that directory. If you only have one web.config and no subdirectories, it applies to all the pages in the root directory.

good luck...

bullpit


thanks but i have many dir's and just need 3 pages to be accessable without loggin in...

can you tell me why that code is not working...


This might help you:

Use role membership to allow only some authenticated users to view Secret/ProtectedPage.aspx.

Without roles:
Deny all unauthenticated users.
<deny users="?" />
Deny all users (users="*") except John and Alice.
<allow users="John, Alice" />
<deny users="*" />
Allow all except Jeff, Bob, and Mary:
<deny users="Jeff, Bob, Mary" />
<allow users="*" />
<allow> and <deny> are order-sensitive.
ASP.NET will stop at <…= "*"> and ignore any statements that appear after it.
------------------------
With roles:
Grant Developer access to Secret.
<allow roles="Developer" />
<deny users="*" />
Map the roles to user accounts so that ASP.NET can determine whether the requestor is a developer or not.
Place the mapping in the AuthenticateRequest event handler (invoked at the beginning of every request).
Can be done in a custom HTTP module or in Global.asax

Here: SECRET is the protected directory

good luck...

bullpit


Well..I found this in your post:

<allow userd="?"/>

Notice the d in userd


also, you have

<deny users="?"/>

this will deny all authenticated users also.


ok let me fix that and give that a try...

0 comments:

Post a Comment