2017-02-20 5 views
0

私はホームページにこれに対するすべての要求をリダイレクトするだけで、その正確URL /アプリの私であれば、もはやexisits /アプリMVC 5のURLのみ

自分のサイト上の仮想ディレクトリを持っている完全な一致を書き換えます次のことを試してみましたが、これはまた、私は問題は使用して正規表現イムであることを知っているが、それに

答えて

0

を修正する方法イムわからないこの

を使用して、それを解決し、URL /予定に

<rule name="RedirectToRoot" patternSyntax="ECMAScript" stopProcessing="true"> 
    <match url="/app$" /> 
    <action type="Redirect" url="/" redirectType="Permanent"/> 
</rule> 

をリダイレクト

<rule name="RedirectToRoot" patternSyntax="ECMAScript" stopProcessing="true"> 
    <match url="^app/(.*)" /> 
    <action type="Redirect" url="{R:1}" redirectType="Permanent"/> 
</rule> 
0

あなたは(routes.MapMvcAttributeRoutesを追加する必要がRouteConfig.csは)

routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 
     // Add the below 
        routes.MapMvcAttributeRoutes(); 
// Add the below ^^ 

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

MVC 5から以下のソリューションを使用することができます;.一度行われ、これはあなたの仕事が終わっ完了すると、あなただけの[ルート(「MyDenfinedURL」)]アクションメソッド上記

[Route("MyDenfinedURL")] 
public ActionResult MyAction() 
     { 
      //My do over the method  
      return View(); 
     } 

マークすることができます。私のソースのリンク:http://www.dotnet-stuff.com/tutorials/aspnet-mvc/understanding-url-rewriting-and-url-attribute-routing-in-asp-net-mvc-mvc5-with-examples

関連する問題