我在服务器上运行了一个asp.net c#web应用程序,我的应用程序在1分钟后仍然将我发送到登录页面,我的服务器提供商说服务器配置没有错,我已经定义了我的web.config文件如下:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="myConnectionString" connectionString="Data Source=123.123.123.123;User ID=myUserID;Password=myPassword;"/>
</connectionStrings>
<system.web>
<sessionState timeout="30"></sessionState>
<compilation debug="true" targetFramework="4.5" defaultLanguage="c#">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5" />
<httpHandlers>
<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</httpHandlers>
<machineKey
validationKey="374A70A6EF0A2F8C1F821D125FCF6503DEA7E9CE467B433086B058D86FAB67338
C3A37E580F29FF27E86D079CC9153E396ABF495821E84C7B7B1F42F4467F1CA"
decryptionKey="C74E21EE5B3C592C62C1BC5E682ED3CC4BD389CCC3AEA317AE1772E0D6750141"
validation="SHA1" decryption="AES"
/>
</system.web>
<system.webServer>
<handlers>
<add name="CaptchaImage" verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</handlers>
<validation validateIntegratedModeConfiguration="false"/>
<httpErrors errorMode="Custom">
<remove statusCode="404"/>
<error statusCode="404" path="~/pr/http404.aspx" responseMode="ExecuteURL"/>
</httpErrors>
</system.webServer>
</configuration>
在我的.aspx文件中,我使用以下代码检查会话
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (Session["user"] == null || userRole() != "Admin")
Response.Redirect("../Default.aspx", false);
else
{
// some code here..
}
}
catch(Exception ex)
{
litAlert.Text = "<div class='alert alert-danger' role='alert'><div><span><strong>An error has occured. Please try again</strong></span ></div></div>";
}
}
非常感谢任何帮助