ASP MVC应用程序没有重定向到指定的Action方法

时间:2015-05-28 05:25:11

标签: asp.net asp.net-mvc asp.net-mvc-4 razorengine

我的LogIn Controller看起来像这样。

public class LogInController : Controller
{
    SchedulerContext schedulerContext = new SchedulerContext();

    [HttpGet]

    public ActionResult LogIn()
    {
        return View();
    }

    [HttpPost]
    public ActionResult LogIn(FormCollection frmCollection)
    {
        //Some Code

        return RedirectToAction("LogIn", "LogIn");
    }


    [HttpPost]
    public ActionResult SignUp(FormCollection frmCollection)
    {
        //Some Code

        return RedirectToAction("SignUpWizard", "SignUpWizard");
    }

}

我的LogIn Controller看起来像这样。

namespace Scheduler.Controllers.UserPanel
{
    public class SignUpWizardController : Controller
    {
        public ActionResult SignUpWizard()
        {
            return View();
        }
    }
}

我的观点看起来像这样。

@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <title>Login</title>
    <link href="~/Content/css/main.css" rel="stylesheet" />
    <link href="~/Content/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <script src="~/Content/js/jquery.js"></script>
</head>
<body>
    <nav class="navbar navbar-custom" role="navigation">
        <div class="container-fluid">
            <h2 class="text-center t-size-change">Login</h2>
        </div>
        <!-- /.container-fluid -->
    </nav>
    <div class="container m-t-150">
        <div class="row">
            <div class="col-md-12">
                <div class="login-tabs">
                    <!-- Nav tabs -->
                    <ul class="nav nav-tabs nav-justified nav-tabs-custom" role="tablist">
                        <li class="active"><a href="#home" role="tab" data-toggle="tab">Login</a></li>
                        <li><a href="#profile" role="tab" data-toggle="tab">Sign up for free</a></li>
                    </ul>
                    <!-- Tab panes -->
                    <div class="tab-content">
                        <div class="tab-pane active custom-tab" id="home">
                            @using (Html.BeginForm("LogIn", "LogIn", FormMethod.Post))
                            {
                                <div class="row">
                                    <div class="col-lg-12">
                                        <div class="form-group">
                                            <input type="email" placeholder="Email Address" class="form-control" name="Email" required>
                                        </div>
                                        <div class="form-group">
                                            <input type="password" placeholder="Password" class="form-control" name="Password" required>
                                        </div>
                                        <input type="submit" value="Login to Tucan Rotas" class="btn btn-success btn-custom" />
                                        <p class="text-center p-10"><a href="#">Forgot your password?</a></p>
                                    </div>
                                </div>
                            }
                        </div>
                        <div class="tab-pane custom-tab" id="profile">
                            @using (Html.BeginForm("SignUp", "LogIn", FormMethod.Post))
                            {
                                <div class="row">
                                    <div class="col-lg-12">
                                        <div class="form-group">
                                            <input type="email" placeholder="Email Address" class="form-control" name="Email" required>
                                        </div>
                                        <div class="form-group">
                                            <input type="password" placeholder="Password" class="form-control" name="Password" required>
                                        </div>
                                        <input type="submit" class="btn btn-success btn-custom" value="Sign up for free" />
                                    </div>
                                </div>
                            }
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="~/Content/plugins/bootstrap/js/bootstrap.min.js"></script>
    <script src="~/Content/js/tab.js" type="text/javascript"></script>
</body>
</html>

当我按下LogIn或SignUp按钮时,应用程序调用LogIn()方法进行装饰 使用HttpGet属性。

当我的应用程序启动时,URL就像这样。

  

http://localhost:56789/LogIn/LogIn?ReturnUrl=%2f

现在我尝试将网址更改为

  

http://localhost:56789/SignUpWizard/SignUpWizard

当我按Enter键时,浏览器将应用程序重定向到SignUpWizard控制器并调用操作方法SignUpWizard,但URL会自动更改为

  

http://localhost:56789/LogIn/LogIn?ReturnUrl=%2fSignUpWizard%2fSignUpWizard

请注意,我不是除了HttpGet或HttpPost之外的任何其他属性的decorate方法。我没有使用任何身份验证或授权。还尝试使用AJAX.BeginForm()以及JQuery AJAX调用提交日期。我无法解决问题。

相同的应用程序昨天使用相同的代码正常工作。

1 个答案:

答案 0 :(得分:0)

  1. 首先,我停止IIS服务。
  2. 应用程序是否包含任何身份验证或授权代码?如果是,则将其删除。
  3. 删除Bin目录。
  4. 再次启动IIS服务。
  5. 再次运行应用程序。