网址路由问题 [英] problem in url routing

查看:80
本文介绍了网址路由问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,我正在我的应用程序中实现网址路由.它工作正常
例如:WebSite1/users/Randeep

我想使用randeep的用户ID,给我用户名.

我的代码是:
Gloabal.asax

hi friends,i am implementing url routing in my application.it work fine
eg:WebSite1/users/Randeep

i want work with user id of randeep,it give me user name.

my code is:
Gloabal.asax

void Application_Start(object sender, EventArgs e)
    {
       RegisterRoutes(RouteTable.Routes);

    }
    public static void RegisterRoutes(RouteCollection routes)
    {
       tes.MapPageRoute("kk", "User/{uname}", "~/default2.aspx");
    }



在首页



in the first page

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
   {
       string Url = Page.GetRouteUrl("kk", new { uname= (DropDownList1.SelectedItem.Text;) });
       Response.Redirect(Url);
   }



在default2.aspx



in default2.aspx

protected void Page_Load(object sender, EventArgs e)
   {
       string name = Page.RouteData.Values["uname"].ToString();
       Int32 uid=?
   }


如何传递uname,uid仅显示名称和访问uid?


how to pass uname,uid display only name and access uid?

推荐答案

报价:

字符串LocationName = SelectDestination.Value;
字符串类别;
Response.Redirect("Search Result.aspx?Location =" + LocationName +& Category =" +类别);

使用上方发送值,并使用以下代码获取值.

位置= Request.QueryString ["Location"].ToString();
类别= Request.QueryString [类别"] .ToString();

String LocationName = SelectDestination.Value;
String Category;
Response.Redirect("Search Result.aspx?Location=" + LocationName + "&Category=" + Category);

Using the Above send the value and using the following code fetch the value.

Location = Request.QueryString["Location"].ToString();
Category = Request.QueryString["Category"].ToString();


这篇关于网址路由问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆