开发者

Subdomain Points To Blog Folder (Non-MVC) on an MVC 3 Site

开发者 https://www.devze.com 2023-02-16 20:11 出处:网络
I have an MVC 3 site that is working and currently quite basic.There is a folder off of the root called Blog where I have BlogEngine.net setup.Both work as I want.I had to do the following code in the

I have an MVC 3 site that is working and currently quite basic. There is a folder off of the root called Blog where I have BlogEngine.net setup. Both work as I want. I had to do the following code in the global.asax file to make sure that MVC would ignore any request going to the Blog folder as follows:

public static void RegisterRoutes(RouteCollection routes) {
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.IgnoreRoute("{folder}/{*pathinfo}", new { folder = "Blog" });

    routes.MapRoute(
        "Default", // Route name
        "{controller}/{action}/{id}", // URL with parameters
        new { controller = "Home",
              action = "Index",
              id = UrlParameter.Optional } // Parameter defaults
    );
}

What I am looking for is to be able to go to: blog.mysite.com and have it go directly to the /blog folder. I have a Subdomain setup through my hosting provider. However, I am not sure what to do beyond this to tell it to go anywhere. When I currently go to blog.mysite.开发者_如何学Ccom, it just takes me to the home page.

I suspect I will have to add a MapRoute assume it will be smart enough to still Ignore the {folder} one.


I think the answer to this question might help you along: Is it possible to make an ASP.NET MVC route based on a subdomain?

0

精彩评论

暂无评论...
验证码 换一张
取 消