【问题标题】:How to rewrite an url in global.asax.cs without using the rewrite rule in web.config?如何在不使用 web.config 中的重写规则的情况下重写 global.asax.cs 中的 url?
【发布时间】:2018-07-15 00:52:02
【问题描述】:

需要您的专家帮助。我正在尝试在不使用重写规则的情况下重写 global.asax.cs 页面中页面的 url。重写 url 的过程发生但页面没有显示。我收到以下错误 “HTTP 错误 404.0 - 未找到 您要查找的资源已被删除、名称已更改或暂时不可用。"

【问题讨论】:

    标签: asp.net url-rewriting global-asax


    【解决方案1】:

    您可以使用System.Web.Routing 从 Global.asax 中进行 URL 重写,例如,

    protected void Application_Start(object sender, EventArgs e)
    {
        RegisterRoutes(RouteTable.Routes);
    }
    public static void RegisterRoutes(RouteCollection routecollection)
    {
        routecollection.MapPageRoute("Login", "Login", "~/Login.aspx");
    }
    

    你可以参考这个link

    【讨论】:

      猜你喜欢
      • 2012-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-26
      • 2013-04-17
      相关资源
      最近更新 更多