如何将用户重新路由到主页面

时间:2014-01-09 10:44:37

标签: html .net routes

我在目录“/country/main.html”中有.html文件。现在,我想在请求到达任何国家/地区时将用户重定向到此页面。我写了一些代码片段

  public class Global : System.Web.HttpApplication
    {
        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            HttpApplication app = sender as HttpApplication;
            if (app.Request.Path.Contains("/country"))
            {
                app.Context.RewritePath("/country/main.html");
            }
        }
    }

我尝试了这个网址http://www.mydomain.com/country,效果很好。但是如果请求到达类似http://www.mydomain.com/country/new_york.html的内容,则会给我404错误。

请建议,在这种情况下我必须做什么?

0 个答案:

没有答案