나는이 코드를 고전적인 코드에 따라 global.asax에 썼다. 웹 사이트를 시작할 때마다이 오류가 표시됩니다. 페이지를 새로 고친 후 올바른 페이지로 이동합니다. 이유를 모르겠습니다.이 컨텍스트에서는 응답을 사용할 수 없습니다. Response.Write (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());
}
}
</스크립트 >
catch가 잡는 예외가 무엇인지 궁금합니다. –
언급 한 코드가 어떤 이벤트에 있습니까? – V4Vendetta