简体   繁体   English

IIS URL重写为App

[英]IIS URL Rewrite to App

I am redesigning an existing website to an ASP.NET MVC. 我正在将现有网站重新设计为ASP.NET MVC。 When deploying I am planning to deploy this as an App in IIS - App is named as -dweb- . 部署时,我计划将其部署为IIS中的应用程序-应用程序名为-dweb-。 Now I need to redirect all the incoming URL to 现在,我需要将所有传入的URL重定向到

http://www.xyz.com to http://www.xyz.com/dweb http://www.xyz.comhttp://www.xyz.com/dweb

However for the end user/browser the url redirect is not transparent, they should not see the redirected url. 但是,对于最终用户/浏览器,URL重定向不是透明的,因此他们不应看到重定向的URL。

Is it better to do in Routing or URL Rewrite Module ? 在“路由”或“ URL重写模块”中做得更好吗? Any sample Route / Rewrite rules ? 有任何示例路由/重写规则吗?

In your RouteConfig.cs (or RouteConfig.vb), change the default route path: 在RouteConfig.cs(或RouteConfig.vb)中,更改默认路由路径:

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{ID}",
            defaults: new { controller = "Home", action = "dweb", id = UrlParameter.Optional }
        );
    }
}

You will need a View named dweb.cshtml under \\Views\\Home to display the page. 您需要在\\ Views \\ Home下有一个名为dweb.cshtml的View才能显示该页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM