Asp .net Global.asax文件 [英] Asp .net Global.asax file
本文介绍了Asp .net Global.asax文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Global.asax下编写了代码。这里的错误信息是页面没有正确重定向......。我如何重定向到另一页..?PLZ SUGGEST ME ...
I had written the code under the Global.asax. Here the error message was "The page isn't redirecting properly...".HOW CAN I REDIRECT TO ANOTHER PAGE..?PLZ SUGGEST ME ...
void Application_BeginRequest(object sender, EventArgs e)
{
cmd = new System.Data.SqlClient.SqlCommand("sp_Checkurl", con_obj.conn);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@url", url);
da = new System.Data.SqlClient.SqlDataAdapter(cmd);
ds = new System.Data.DataSet();
da.Fill(ds);
con_obj.Conn_close();
if (ds.Tables[0].Rows.Count > 0)
{
HttpContext.Current.Response.Redirect(url);
Dispose();
}
else
{
HttpContext.Current.Response.Redirect("http://localhost:51262/Mywebsite/Blankpage.aspx");
Dispose();
}
}
推荐答案
而不是
HttpContext.Current.Response.Redirect(url);
尝试写
try writing
Server.Transfer(url)
看看它是否有效。
你好我是桑尼。我们应该把下面唯一一个重定向页面如下
Hi i am sanny.Here we should put the only one redirect page like below
if (ds.Tables[0].Rows.Count==0)
{
HttpContext.Current.Response.Redirect(url);
Dispose();
}
if (Request.Url.OriginalString.Contains("handler.aspx?menu_id="))
{
Context.RewritePath("~/Handler.aspx");
return;
}
它应该是这样的,并且下一个声明的回报不应该实现
问......:)
it should be like this and return for next statement should not be implemented
regards...:)
这篇关于Asp .net Global.asax文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文