我开发了一个 .NET 4.0 ASP.NET 网站。一切都在当地工作得很好。在 IIS7.5 上开发,WS2008R2 Enterprise + 所有更新。
我部署到 WS2003 服务器。除了当我登录网站(Forms auth)时,它几乎都可以正常工作,它会将我重定向回登录页面!没有错误,什么都没有。有时,当我设法通过它并导航到另一个页面或执行诸如单击按钮之类的操作时,我会被重定向回登录页面!
确信服务器设置存在问题,IT 人员安装了 WS2008R2 + 所有更新。太好了 - 所以我将网站部署在上面。你猜怎么着?还是一样的问题!
是什么赋予了?为什么它会在您登录(没有代码这样做)或执行操作时重定向回登录页面?
另一件事是,我正在使用 Telerik 控件以及 ASP.NET AJAX 扩展器。服务器似乎没有加载它们(服务器和客户端都没有错误)。应该有下拉菜单,除了要弹出的 AJAX 日历之外,它不起作用 - 这也不起作用。
我不确定现在该怎么做,因为这令人沮丧,而且我从来没有遇到过这样的问题。
这是我的配置文件的一部分:
<configSections>
<sectionGroup name="system.web">
<section name="sanitizer" requirePermission="false" type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, AjaxControlToolkit"/>
</sectionGroup>
</configSections>
<system.web>
<globalization culture="en-gb" uiCulture="en-gb"/>
<httpRuntime maxRequestLength="100240"/>
<trust level="Full"/>
<sanitizer defaultProvider="HtmlAgilityPackSanitizerProvider">
<providers>
<add name="HtmlAgilityPackSanitizerProvider" type="AjaxControlToolkit.Sanitizer.HtmlAgilityPackSanitizerProvider"/>
</providers>
</sanitizer>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="Telerik.Web.UI, Version=2012.3.1017.40, Culture=neutral, PublicKeyToken=949410a6b6ad1e71"/>
</assemblies>
</compilation>
<sessionState mode="InProc" timeout="30"/>
<authentication mode="Forms">
<forms name="RegisteredUsers" defaultUrl="~/Help/About.aspx" path="/" protection="All" loginUrl="~/Account/Login.aspx" timeout="31"/>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<httpHandlers>
<add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false"/>
</httpHandlers>
</system.web>
<location path="Account">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<location path="Public">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<location path="Styles">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<location path="Scripts">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<location path="Images">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<location path="Help">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource"/>
</handlers>
</system.webServer>
至于验证码:
// log them in and authenticate
FormsAuthentication.SetAuthCookie(this.txtUsername.Text, false);
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, this.txtUsername.Text, DateTime.Now, DateTime.Now.AddYears(1), false, this.txtUsername.Text);
// For security reasons we may hash the cookies
string hashCookies = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hashCookies);
cookie.Path = FormsAuthentication.FormsCookiePath;
cookie.Expires = ticket.Expiration;
// add the cookie to user browser
Response.Cookies.Add(cookie);
Session[CommonStrings.USER_LOGGED_IN] = userResponse.User;
// if DefaultWebPage is not null then redirect to that otherwise, default behavior.
if (!string.IsNullOrWhiteSpace(userResponse.User.DefaultWebPage))
{
Response.Redirect(userResponse.User.DefaultWebPage, false);
}
else
{
FormsAuthentication.RedirectFromLoginPage(this.txtUsername.Text, false);
}