0

我在访问 HomeController 上的方法时遇到问题。我向您展示该方法的代码:

[HttpGet]
    public ActionResult DecriptIdentifiantEtRedirige(string login_crypter, string mdp_crypter)
    {
        string loginAcrypter = _globalManager.ProtegeMotDePasse(login_crypter);
        string MdpAcrypter = _globalManager.ProtegeMotDePasse(mdp_crypter);
        User UserApp = new Models.User(login_crypter, mdp_crypter);
        if (UserApp.AuthentificationValidee(UserApp.UserLogin, UserApp.Password))
        {
            Session["Name"] = UserApp.UserLogin;
            return RedirectToAction("Accueil", "Home");
        }
        else
        {

            return RedirectToAction("ValiderAuthentification", "Home");
        }

    }

然后在 RouteConfig.cs 我写了这样的路线:

routes.MapRoute(
        name: "AuthentificationApresDecryptage",
        url: "{controller}/{action}/{login_crypter}/{mdp_crypter}",
        defaults: new { controller = "Home", action = "DecriptIdentifiantEtRedirige", login_crypter = "", mdp_crypter = "" }
        );

但问题是,当我尝试在浏览器中使用该链接访问该方法时:“ http://mydomain.com/DecriptIdentifiantEtRedirige/12345/54321 ”它向我显示一个错误:“找不到资源”。

有人有想法吗?谢谢。

4

1 回答 1

2

尝试这个,

routes.MapRoute(
        name: "AuthentificationApresDecryptage",
        url: "{controller}/{action}/{login_crypter}/{mdp_crypter}",
        defaults: new { controller = "Home", action = "DecriptIdentifiantEtRedirige", login_crypter = UrlParameter.Optional, mdp_crypter = UrlParameter.Optional }
        );
于 2013-07-25T09:49:16.593 回答