【发布时间】:2015-04-16 12:25:31
【问题描述】:
我正在尝试进行重定向,我有一个作为我的配置类的单例类,获取了关于此的信息并使用了我的连接字符串,我将这些数据保存在加密文件中,我正在使用 session-per-请求,然后在安装之前我需要检查会话配置文件,如果没有我会抛出异常。
protected void Application_BeginRequest()
{
if (!Settings.Data.Valid())
throw new SingletonException();
var session = SessionManager.SessionFactory.OpenSession();
if (!session.Transaction.IsActive)
session.BeginTransaction(IsolationLevel.ReadCommitted);
CurrentSessionContext.Bind(session);
}
如果除了我必须重定向到设置页面,这是一个单例类。
protected void Application_Error(Object sender, EventArgs e)
{
Exception exc = Server.GetLastError();
while (exc != null)
{
if (exc.GetType() == typeof(SingletonException))
{
Response.Redirect(@"~/Settings/Index");
}
exc = exc.InnerException;
}
}
但是我在重定向时遇到了问题,浏览器中的链接正在更改,但我有一个重定向循环,已经尝试清除 cookie 并启用外部站点的选项。 有人可以帮我吗?
【问题讨论】:
标签: c# redirect model-view-controller session-per-request