找不到资源错误

本文关键字:错误 资源 找不到 | 更新日期: 2023-09-27 18:25:03

我在访问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"它显示了一个错误:"找不到资源"。

有人有主意吗?谢谢

找不到资源错误

试试这个,

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 }
        );