【发布时间】:2011-05-08 02:03:15
【问题描述】:
我刚刚构建了一个带有表单身份验证的应用程序。我无法在应用程序中看到我的样式(在成功登录后在 Login.aspx 或页面上进行身份验证之前)。当应用程序使用 Windows 身份验证时,它们曾经是可访问的。
我阅读了另一个论坛,上面说您必须在验证之前授予对包含 css 的 App_Themes 文件夹的访问权限,但请再次阅读以上内容(验证后我也看不到它们)。这在使用 Windows 身份验证之前有效。我引入了另一个菜单库,所以你现在会看到 3 个部分。
我使用的是 Windows 7。哦,我右键单击了包含我的网站文件的根文件夹。我在 IIS 7 中添加了 IIS_IUSRS 组和 IIS APPPOOL[APP POOL NAME] 的权限。我将所有权限都授予了。此外,我启用了基本身份验证,并在我的站点中启用了表单身份验证。其余被禁用。
感谢堆栈溢出天才!!
===========================
web.config
Visual Studio 中的 Asp.Net 配置选项。 设置和 cmets 的完整列表可以在 machine.config.cmets 通常位于 \Windows\Microsoft.Net\Framework\v2.x\Config --><compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<!--<authentication mode="Forms">
<forms cookieless="UseCookies" slidingExpiration="true"
protection="All" timeout="60" loginUrl="~/Login.aspx">
</forms>
</authentication>
<authorization>
<deny users="?" />
<allow users="*"/>
</authorization>-->
<authentication mode="Forms">
<forms name="WANTA-AUTHENTICATE"
loginUrl="Login.aspx"
protection="All"
timeout="5"
path="/">
<credentials passwordFormat="MD5" />
</forms>
</authentication>
<authorization>
<allow users="*"/>
<deny users="?" />
</authorization>
<customErrors mode="Off" defaultRedirect="Default.aspx">
</customErrors>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
<!-- SESSION STATE SETTINGS
By default ASP.NET uses cookies to identify which requests belong to a particular session.
If cookies are not available, a session can be tracked by adding a session identifier to the URL.
To disable cookies, set sessionState cookieless="true".
-->
<sessionState mode="InProc" timeout="55" />
<system.serviceModel>
<!--<serviceHostingEnvironment aspNetCompatibilityEnabled="true" >
<baseAddressPrefixFilters>
<add prefix="http://localhost/" />
</baseAddressPrefixFilters>
</serviceHostingEnvironment>-->
<behaviors>
<endpointBehaviors>
<behavior name="AspNetAjaxBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Wanta.Toolkit.WantaService" behaviorConfiguration="ServiceBehavior">
<endpoint behaviorConfiguration="AspNetAjaxBehavior" binding="webHttpBinding" contract="Wanta.Toolkit.WantaService" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
===================
登录.aspx.cs
protected void Logon_Click(object sender, EventArgs e)
{
if ((UserEmail.Text == "x") &&
(UserPass.Text == "x"))
{
FormsAuthentication.RedirectFromLoginPage
(UserEmail.Text, Persist.Checked);
}
else
{
Msg.Text = "Invalid credentials. Please try again.";
}
}
【问题讨论】: