我在Global.asax以下經典代碼寫了這個代碼。每次我啓動網站時,都會顯示此錯誤。在我刷新頁面後,它進入正確的頁面。我不明白爲什麼。響應在此上下文中不可用。回覆於(ex.ToString());
Response is not available in this context. 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.Web.HttpException: Response is not available in this context.
Source Error:
Line 26: catch (Exception ex) Line 27: { Line 28: Response.Write(ex.ToString()); Line 29: } Line 30:
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
try
{
if (Roles.RoleExists("Administrators") == false)
Roles.CreateRole("Administrators");
if (Membership.FindUsersByName("ken").Count == 0)
{
Membership.CreateUser("ken", "123", "[email protected]");
Roles.AddUserToRole("ken", "Administrators");
}
if (Membership.FindUsersByName("dan").Count == 0)
Membership.CreateUser("dan", "123", "[email protected]");
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
< /腳本>
我不知道什麼異常捕獲正在迎頭趕上? – 2011-03-25 05:55:06
您提到的代碼在哪個事件中存在? – V4Vendetta 2011-03-25 05:56:51