我使用了以下代码,但我无法访问我的查询字符串......
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));
}
全球.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");
请帮我。