简体   繁体   English

web.config“location”出错

[英]Error in web.config “location”

My site has 2 logins. 我的网站有2次登录。 1 on the front end for regular users, and one in the admin section, for admins (I need 2 logins because each one asks for different login criteria). 对于常规用户,前端为1,管理员部分为1,对于管理员(我需要2次登录,因为每个人都要求不同的登录标准)。 To authenticate the admin directory, I setup a "location" element in my main site's web.config like this: 要验证admin目录,我在主站点的web.config中设置了一个“location”元素,如下所示:

<location path="Admin">
<system.web>
  <authentication mode="Forms" >
    <forms loginUrl="/Accounts/adminLogin.aspx"/>
  </authentication>
  <authorization>
    <deny users="?"/>
  </authorization>
</system.web>

If I try to type any page from my "Admin" directory, into my browser, I get the following error: 如果我尝试从我的“管理”目录中键入任何页面,进入我的浏览器,我会收到以下错误:

It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. 在应用程序级别之外使用注册为allowDefinition ='MachineToApplication'的部分是错误的。 This error can be caused by a virtual directory not being configured as an application in IIS. 此错误可能是由于未在IIS中将虚拟目录配置为应用程序引起的。

How can I setup my location element to redirect properly? 如何设置我的位置元素以正确重定向?

Thanks 谢谢

There are mainly one of the two reason why you got this error message. 您收到此错误消息的原因主要有两个。

  1. If you have not configured your asp.Net application in iis. 如果您尚未在iis中配置asp.Net应用程序。 If you have not configure your application to run on iis first configure your site to run on iis.For that create virtual directory from iis and give permission to application (read,write) 如果您尚未将应用程序配置为在iis上运行,请首先将站点配置为在iis上运行。为此从iis创建虚拟目录并授予应用程序权限(读取,写入)
  2. If above is not problem then there are mainly problem of two or many web.Config exists on your site.When you open some site and if software crate backup of that application then software mainly do create subfolder and copy all files + web.Config in application.Just remove this subfolder web.Config from subfolder. 如果上面没有问题则主要存在两个或多个web.Config存在于您的网站上的问题。当您打开某个网站并且如果该应用程序的软件包备份那么软件主要创建子文件夹并复制所有文件+ web.Config in application.Just从子文件夹中删除此子文件夹web.Config。

Check the web.Config in your admin folder and main root folder for settings and configurations. 检查管理文件夹和主根文件夹中的web.Config以获取设置和配置。

You can't change the Authentication mode within a subdirectory. 您无法在子目录中更改身份验证模式。 Only WebApplications can define this setting which applies to the entire application. 只有WebApplications可以定义适用于整个应用程序的此设置。 A location element is only used in subdirectories to change authorization, not authentication settings. location元素仅在子目录中用于更改授权,而不是身份验证设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM