2011-06-06 29 views

回答

0

您將要離開正常路線的尾部斜線,否則它表示可能有網址參數進入動作。

要強制執行此操作,您可能需要查看MvcCms中的cleanurl過濾器。 Source Code

private bool IsTrailingSlashDirty(ref string path) 
    { 
     //we only want a trailing slash on the homepage 
     if (path.EndsWith("/") && !path.Equals("/")) 
     { 
      path = path.TrimEnd(new char[] { '/', '/' }); 
      return true; 
     } 
     return false; 
    } 
+0

MvcCmsJon,感謝您的回覆。你是對的,用你的代碼,網址顯然會清楚。 – Feng 2011-06-07 14:04:20

1

我發現問題,這是由頁面緩存引起的。爲了避免這個問題,我將代碼修改爲:

[OutputCache(Duration = 30, VaryByCustom = "Request.IsAuthenticated")] 
public ActionResult Index() 
{ 
    if (Request.IsAuthenticated) 
    { 
     return RedirectToAction("Index", "Member"); 
    } 
    else 
    { 
     return View(); 
    } 
} 

現在就起作用了。