zoukankan      html  css  js  c++  java
  • Asp.Net路由重写为用户名或者ID

    有一个需求如下:指定某个Area的路由(Area:Wx)在其后面添加用户名或者ID作为URL参数,即像下面的样子:

    /Wx/xiaoming/

    /Wx/xiaoming/photo

    /Wx/xiaoming/photo/manage?oid=34

    这样的话修改一下路由就好了,如下:

    context.MapRoute(
      "Wx_rester_with_id2",
      "Wx/{rid}/{controller}/{action}/",
      new { controller = "Rester", action = "Index", rid = "" }
    );

     获取参数的话正常获取就可以了,即:

    public ActionResult Lili(long id)
    {
      var rid = this.RouteData.Values["rid"];
      return Content("user yes:" + id);
    }
  • 相关阅读:
    python
    C++的socket编程学习
    GooglePlay
    GooglePlay
    Admob
    cocos2dx
    cocos2dx
    cocos2dx
    cocos2dx
    浅谈白鹭Egret
  • 原文地址:https://www.cnblogs.com/huangsheng/p/6422888.html
Copyright © 2011-2022 走看看