Search code examples
asp.netasp.net-mvcasp.net-mvc-4razorengine

ASP MVC application not redirect to specifed Action Method


My LogIn Controller look like this.

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

}

My LogIn Controller look like this.

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

My View look like this.

@{
    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>

When I Press LogIn or SignUp button, Application calling LogIn() method decorate with HttpGet attribute.

When my application starts URL Look Like this.

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

Now I tried to Change URL to

http://localhost:56789/SignUpWizard/SignUpWizard

When I hit Enter, Browser redirect application to SignUpWizard Controller and call action method SignUpWizard, But URL change automatically to

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

Please note that,I am not decorate method with any other attribute except HttpGet Or HttpPost. I am not use any authentication or Authorization. Also try to submit date using AJAX.BeginForm() as well as JQuery AJAX call. I am fail to solve problem.

Same application working properly with same code yesterday.


Solution

    1. First of all I stop IIS services.
    2. Does application contain any authentication or authorization code?If yes then remove it.
    3. Delete Bin directory.
    4. Start IIS services again.
    5. Run Application once again.