Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIS Config for Directories, Subdirectories and Forms Auth. 1

Status
Not open for further replies.

jmeckley

Programmer
Jul 15, 2002
5,269
US
I have a simple app that has the following structure
[tt][opsreport]
web.config
clientside.js
styles.css
logon.aspx
default.aspx
summary.aspx
[dataentry]
event.aspx
followup.aspx[/tt]
opsreport is configured as an application virutal directory in IIS. dataentry is just a sub folder.

anyone can access the opsreport directory. Only authenticated users can access the pages in the dataentry directory.

when I click the link to access opsreport/dataentry/event.aspx I get the following error
[tt]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.

It errored on this line of the web.config file
<authentication mode="Forms>[/tt]

I don't think I need to configure each subdirectory as an application. That doesn't make sense.

For testing purposes I did create the dataentry folder as an appliaction in IIS. When I accessed the event.aspx page I was prompted for my username and password. When I clicked Logon I was brought back to the logon page. I know my uid/pwd were OK because if they weren't I would get a message *Invalid Logon*.

I removed the Forms Authentication from the dataentry directory to see what the issue was. Now when I accessed the event.aspx it errored on the first line of the aspx.file
[tt]<%@ Page Language="vb" AutoEventWireup="false" Codebehind="event.aspx.vb" Inherits="opsreport._event" %>
[/tt]
stating it can't find the code for the page.

This might be because there is no bin directory in the dataentry folder. All the code was compiled and placed in the bin directory on the root.

here is my web.config file
Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <location path="dataentry">
    <system.web>
      <authentication mode="Forms" >
        <forms
          name=".opsreport" 
          loginUrl="../logon.aspx" 
          protection="All"
          slidingExpiration="true" 
	  timeout = "10"
        />
      </authentication>
      <authorization>
        <deny users="?" />
      </authorization>
    </system.web>
  </location>
  <system.web>
  <compilation defaultLanguage="vb" debug="true" />
  <customErrors mode="RemoteOnly" />
  <authentication mode="None" />
  <trace
    enabled="false" 
    requestLimit="10" 
    pageOutput="false" 
    traceMode="SortByTime" 
    localOnly="true" 
  />
  <sessionState 
    mode="InProc"	   
    stateConnectionString="tcpip=127.0.0.1:42424"
    sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
    cookieless="false" 
    timeout="20" 
  />
  <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
  </system.web>
</configuration>

What do I need to do, to use forms authentication on a sub directory? Thank you in advance for your help.

Jason Meckley
Database Analyst
WITF
 
I finally found an answer!

web.config
Code:
<location path="dataentry">
  <system.web>
    <authorization>
      <deny users="?" />
      <allow users="*" />
    </authorization>
  </system.web>
</location>
<location>
  <system.web>
    <authentication mode="Forms" >
      <forms
        name=".opsreport" 
        loginUrl="logon.aspx" 
        protection="All"
        slidingExpiration="true" 
        timeout = "10"
      />
    </authentication>
    <authorization>
      <allow users="?" />
    </authorization>
...


Jason Meckley
Database Analyst
WITF
 
Excellent, it also helped me to set up impersonation on a webservice in a folder without needing another webconfig file.

Thanks for the link Jason ...

Ed (RoadRacer) Holguin

&quot;I Hate Computers!&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top