比如我输入:
http://www.test.com/
http://www.test.com/1/
http://www.test.com/blog/post
则分别访问以下页面:
~/html/www.test.com/index.html
~/html/www.test.com/1/index.html
~/html/www.test.com/blog/post.aspx请知道的大侠顺便给出示例router的示例,多谢!

解决方案 »

  1.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using System.Web.Routing;namespace MvcApplication1
    {
        // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
        // visit http://go.microsoft.com/?LinkId=9394801    public class MvcApplication : System.Web.HttpApplication
        {
            public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");            routes.MapRoute(
                    "Default", // Route name
                    "{controller}/{action}/{id}", // URL with parameters
                    new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
                );            ViewEngines.Engines.Add(new WebFormViewEngine()
                {
                    ViewLocationFormats = new string[] { "~/html/www.test.com/{1}/{0}.aspx" }
                });        }        protected void Application_Start()
            {
                AreaRegistration.RegisterAllAreas();            RegisterRoutes(RouteTable.Routes);
            }
        }
    }
      

  2.   

    没用,不知道是不是我没有讲清除,我是想在一个IIS站点里面,绑定N个域名,然后每个域名绑定不同的站点,站点的内容分别由后台程序生成静态页面存于“~/html/域名/*”里面,这样通过某域名(当前域名是很容易获取到的哈)访问就像在对应的目录一样:输入http://www.a.com/访问的实际文件地址是http://www.a.com/html/www_a_com/index.html
    输入http://www.a.com/1访问的实际文件地址是http://www.a.com/html/www_a_com/1/index.html
    输入http://www.a.com/blog/post访问的实际文件地址是http://www.a.com/html/www_a_com/blog/post.aspx输入http://www.b.com/访问的实际文件地址是http://www.b.com/html/www_b_com/index.html
    输入http://www.b.com/1访问的实际文件地址是http://www.b.com/html/www_b_com/1/index.html
    输入http://www.b.com/blog/post访问的实际文件地址是http://www.b.com/html/www_b_com/blog/post.aspx
      

  3.   


    ASP.NET MVC 是一个包含大量约定的 MVC 框架。
    它的目标是,实现约定优于配置(CoC)的价值观,也就是如果你认可它的约定,它可以大大简化你的工作,否则,使用ASP.NET MVC还不如不用它。
      

  4.   

    我的系统本身是基于MVC2做的,只是现在想要升级,把能静态化的部分静态化处理,另外就是想利用mvc的router做一下映射,不过我对这个router还不够熟悉,所以才求助的。
      

  5.   

    这个问题我现在找到了个比较勉强的解决办法,就是在global里面路由设置的顶端拦截,将对某一子目录(比如HTML目录)下的访问(如http://www.test.com/html/nihao/)指向“域名文件夹/×”(http://www.test.com/www_test_com/nihao/index.html),正在准备把域名夹方式改为根据配置文档读出每个域名对应的根文件夹,在初始化时将配置文件读到static List<DomainModel>中,访问时,若能被拦截到,就直接从list中去取对应的根。