我突然得到以下错误。我的应用程序工作正常,直到我可能修改了一些东西,但不知道是什么
Server Error in '/' Application.
--------------------------------------------------------------------------------
Method is only supported if the user name parameter matches the user name in the current Windows Identity.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Configuration.Provider.ProviderException: Method is only supported if the user name parameter matches the user name in the current Windows Identity.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ProviderException: Method is only supported if the user name parameter matches the user name in the current Windows Identity.]
System.Web.Security.WindowsTokenRoleProvider.GetCurrentWindowsIdentityAndCheckName(String userName) +2195661
System.Web.Security.WindowsTokenRoleProvider.GetCurrentTokenAndCheckName(String userName) +36
System.Web.Security.WindowsTokenRoleProvider.GetRolesForUser(String username) +61
System.Web.Security.RolePrincipal.IsInRole(String role) +182
System.Web.Configuration.AuthorizationRule.IsTheUserInAnyRole(StringCollection roles, IPrincipal principal) +132
System.Web.Configuration.AuthorizationRule.IsUserAllowed(IPrincipal user, String verb) +256
System.Web.Configuration.AuthorizationRuleCollection.IsUserAllowed(IPrincipal user, String verb) +201
System.Web.Security.UrlAuthorizationModule.OnEnter(Object source, EventArgs eventArgs) +8890701
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
我只是尝试访问受以下
保护的目录中的aspx文件<?xml version="1.0"?>
<configuration>
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</configuration>
没有
它可以正常工作<deny users="?"/>
我该怎么办? 我认为我的申请被称为'/'并不正常。我觉得我在配置文件中有一个明确的应用程序名称,但可能在一个部分中缺少它?
这是我的配置文件:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
</appSettings>
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
<listeners>
<add listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.CustomTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" type="MyAppConfig.Business.DebugTraceListener, MyAppConfig.Business, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="DebugTraceListener" formatter="" />
<add name="Database Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" databaseInstanceName="MyAppConfigLogging" writeLogStoredProcName="WriteLog" addCategoryStoredProcName="AddCategory" formatter="Text Formatter" />
</listeners>
<formatters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="Timestamp: {timestamp}{newline}
Message: {message}{newline}
Category: {category}{newline}
Priority: {priority}{newline}
EventId: {eventid}{newline}
Severity: {severity}{newline}
Title:{title}{newline}
Machine: {localMachine}{newline}
App Domain: {localAppDomain}{newline}
ProcessId: {localProcessId}{newline}
Process Name: {localProcessName}{newline}
Thread Name: {threadName}{newline}
Win32 ThreadId:{win32ThreadId}{newline}
Extended Properties: {dictionary({key} - {value}{newline})}" name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="General" />
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors & Warnings" />
</specialSources>
</loggingConfiguration>
<dataConfiguration defaultDatabase="MyAppConfigLogging" />
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="DomainServiceModule" preCondition="managedHandler" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ChartImageHandler" />
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
</system.webServer>
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Application Name=/MyAppConfig;Data Source=.\SQLEXPRESS;Initial Catalog=MyAppConfig;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="MyAppConfigLogging" connectionString="Application Name=/MyAppConfig;Data Source=.\SQLEXPRESS;Initial Catalog=MyAppConfigLogging;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="MyAppConfigConnection" connectionString="Application Name=/MyAppConfig;Data Source=.\SQLEXPRESS;Initial Catalog=MyAppConfig;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="MyAppConfigEntities" connectionString="metadata=res://*/ModelMyAppConfig.csdl|res://*/ModelMyAppConfig.ssdl|res://*/ModelMyAppConfig.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;Initial Catalog=MyAppConfig;Integrated Security=True;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" />
<add name="MyAppConfigEntities1" connectionString="metadata=res://*/MyAppConfig.csdl|res://*/MyAppConfig.ssdl|res://*/MyAppConfig.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;Initial Catalog=MyAppConfig;Integrated Security=True;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" />
<add name="MyAppConfigConnectionString" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=MyAppConfig;Integrated Security=True;MultipleActiveResultSets=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<!--<authorization>
<deny users="?"/>
</authorization>-->
<httpHandlers>
<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
</httpHandlers>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</controls>
</pages>
<anonymousIdentification enabled="true" />
<authorization>
<allow roles="Admin" />
</authorization>
<authentication mode="Forms" >
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
<providers>
<clear />
<add name="SqlProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="MyAppConfigConnection"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
applicationName="/MyAppConfig"
requiresUniqueEmail="true"
minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="0"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
passwordAttemptWindow="10"
passwordStrengthRegularExpression="" />
</providers>
</membership>
<profile defaultProvider="SqlProvider">
<providers>
<clear/>
<add name="SqlProvider" type="System.Web.Profile.SqlProfileProvider"
connectionStringName="MyAppConfigConnection" applicationName="/MyAppConfig" />
</providers>
<properties>
<add name="FriendlyName" />
<add name="NbOfVisits" allowAnonymous="true" type="System.Int32" />
</properties>
</profile>
<roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider" >
<providers>
<clear />
<add connectionStringName="MyAppConfigConnection" applicationName="/MyAppConfig" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" />
<add applicationName="/MyAppConfig" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" />
</providers>
</roleManager>
<httpModules>
<add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</httpModules>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<client />
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.ConfiguratorService.customBinding0">
<binaryMessageEncoding />
<httpTransport />
</binding>
<binding name="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.FinanceService.customBinding0">
<binaryMessageEncoding />
<httpTransport />
</binding>
<binding name="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.UserErrorReportService.customBinding0">
<binaryMessageEncoding />
<httpTransport />
</binding>
<binding name="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.StatService.customBinding0">
<binaryMessageEncoding />
<httpTransport />
</binding>
<binding name="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.MyAppConfigAuthenticationService.customBinding0">
<binaryMessageEncoding />
<httpTransport />
</binding>
<binding name="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.DataDisplayService.customBinding0">
<binaryMessageEncoding />
<httpTransport />
</binding>
</customBinding>
</bindings>
<services>
<service name="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.ConfiguratorService">
<endpoint address="" binding="customBinding" bindingConfiguration="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.ConfiguratorService.customBinding0"
contract="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.ConfiguratorService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
<service name="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.FinanceService">
<endpoint address="" binding="customBinding" bindingConfiguration="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.FinanceService.customBinding0"
contract="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.FinanceService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
<service name="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.UserErrorReportService">
<endpoint address="" binding="customBinding" bindingConfiguration="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.UserErrorReportService.customBinding0"
contract="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.UserErrorReportService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
<service name="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.StatService">
<endpoint address="" binding="customBinding" bindingConfiguration="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.StatService.customBinding0"
contract="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.StatService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
<service name="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.MyAppConfigAuthenticationService">
<endpoint address="" binding="customBinding" bindingConfiguration="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.MyAppConfigAuthenticationService.customBinding0"
contract="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.MyAppConfigAuthenticationService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
<service name="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.DataDisplayService">
<endpoint address="" binding="customBinding" bindingConfiguration="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.DataDisplayService.customBinding0"
contract="MyAppConfig.Silverlight.ConfigEnhanced.Web.Services.DataDisplayService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<!--<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://MyAppConfig.com/" />
</baseAddressPrefixFilters>
</serviceHostingEnvironment>-->
</system.serviceModel>
</configuration>
答案 0 :(得分:2)
您已配置WindowsTokenRoleProvider,但似乎未在该roleprovider中配置用户名。