0

私はユーザーエリアを持っており、この中に以下を登録しています:

context.MapRoute("DefaultRedirect",
    "",
    new { controller = "Account", action = "Login" }
);  

routeDebugを使用すると、自分のサイトwww.xxx.comに接続すると、電話をかけようとすることがわかります。

area = User, controller = Account, action = Login

www.xxx.com/User/Account/Loginを使用して直接接続すると、ログインページが表示されます。

routeDebugを使用せずに自分のサイトwww.xxx.comに接続すると、次のようなエラーメッセージが表示されます。

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /

これが私のコントローラーアクションメソッドです:

   public class AccountController : Controller
    {
        //
        // GET: /Account/Login

        [AllowAnonymous]
        public ActionResult Login()
        {
            ViewBag.ReturnUrl = "xx";
            return View("~/Areas/User/Views/Account/Login.cshtml");
        }

routeDebugが正しいコントローラーとアクションに移動していることを示しているように見えるので、私は非常に混乱していますが、それを使用せずにブレークポイントを設定すると、コントローラーのアクションに移動していないようです。

4

2 に答える 2

0

このコントローラーが同じエリア内にある場合は、使用できると思います

[AllowAnonymous]
    public ActionResult Login()
    {
        ViewBag.ReturnUrl = "xx";
        return View();
    }

どちらの方法でも、使用できるさまざまな領域のビューのみがある場合

return View("~/Views/YourArea/YourController/YourView.aspx");
于 2013-01-11T16:25:55.733 に答える
0
 return RedirectToAction("Login", "Account");

特定のコントローラーと特定のアクションにリダイレクトします。アカウントがフォルダの奥にある場合は、パスを含めるだけです

于 2013-01-11T15:43:54.933 に答える