0
我用下面的代碼使用路由在asp.net 3.5中,但我不能夠進入我的查詢字符串......如何在Web表單
public class RouteHandler : IRouteHandler
{
string _virtualPath;
public RouteHandler(string virtualPath)
{
_virtualPath = virtualPath;
}
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
foreach (var value in requestContext.RouteData.Values)
{
//requestContext.HttpContext.Items[value.Key] = value.Value;
// requestContext.HttpContext.
//System.Web.HttpContext.Items[value.Key] = value.Value;
}
return (Page)BuildManager.CreateInstanceFromVirtualPath(_virtualPath, ypeof(Page));
}
的Global.asax .... .........
private void RegisterRoutes(RouteCollection routes)
{
routes.Add("home", new Route("home", new RouteHandler("default.aspx")));
datatable dt = getmyurl();
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{ try
{
routes.Add(dr["tag"].ToString() + "/" + dr["Ntag"].ToString(), new Route("{Pid}/{Cid}", new RouteHandler("~/test1/test1.aspx")));
}
catch (Exception exx){}
}
}
}
現在我無法查詢字符串了。我認爲我的自定義RouteHandler編碼不好。我有我的默認頁面上的按鈕,我重定向我的頁面
Response.Redirect(dt.Rows[0]["tag"].ToString() + "/" + dt.Rows[0]["Ntag"].ToString());//
response.redirect("goa/agra");
請幫助我。