我想在测试后在Session_Start
中停止我的应用程序asp.net Mvc并向用户显示他未获得此应用程序的授权
protected void Session_Start(object sender, EventArgs e)
{
if (test)
{
//stop application
// say to user : not authorized
}
}
答案 0 :(得分:0)
最后,我发送一个回复并关闭会话,它可以正常工作
protected void Session_Start(object sender, EventArgs e)
{
if (test)
{
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "<h2 style=\"color:RED;\">Vous n'avez pas l'authorisation pour utiliser Application!!</h2>. ";
byte[] data = encoding.GetBytes(postData);
char[] buf = postData.ToCharArray();
HttpContext.Current.Response.Write(buf, 0, buf.Count());
HttpContext.Current.Response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();
Session.Abandon();
}
}