当我尝试重定向到特定视图时,我的应用程序在下面指定的语句中抛出System.NullReferenceException。
此异常发生在App_Web _ *****。dll中,并且不会详细处理。
我在此应用程序中没有使用任何主页或布局。我试图删除Layout = null并将ViewBag.Title =" SignUp",但它会导致同样的问题。
public class SignUpWizardController : Controller
{
//
// GET: /SignUpWizard/
public ActionResult SignUpWizard()
{
return View(); //This Function Call Below 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="~/Scripts/knockout-2.2.0.js"></script>
<script src="~/Scripts/knockout-2.2.0.debug.js"></script>
<script src="~/Content/js/jquery.js"></script>
<script src="~/ViewModel/LoginViewModel.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">
<div class="row">
<div class="col-lg-12">
<div class="form-group">
<input type="email" placeholder="Email Address" class="form-control" name="Email" id="txtLogInEmail" required>
</div>
<div class="form-group">
<input type="password" placeholder="Password" class="form-control" name="Password" id="txtLogInPassword" required>
</div>
<input type="button" value="Login to Tucan Rotas" class="btn btn-success btn-custom" id="btnLogIn" />
<p class="text-center p-10"><a href="#">Forgot your password?</a></p>
</div>
</div>
</div>
<div class="tab-pane custom-tab" id="profile">
<div class="row">
<div class="col-lg-12">
<div class="form-group">
<input type="email" placeholder="Email Address" class="form-control" name="Email" id="txtSignUpEmail" required>
</div>
<div class="form-group">
<input type="password" placeholder="Password" class="form-control" name="Password" id="txtSignUpPassword" required>
</div>
<input type="button" id="btnSignUp" 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>
<script>
$(function () {
$('#btnSignUp').click(function (e) {
e.preventDefault();
$.ajax({
url:'@Url.Action("SignUp", "LogIn")',
method:"POST",
data: { Email: $('#txtSignUpEmail').val(), password: $('#txtSignUpPassword').val() }
});
});
$('#btnLogIn').click(function (e) {
e.preventDefault();
$.ajax({
url: '@Url.Action("LogIn", "LogIn")',
method: "POST",
data: { Email: $('#txtLogInEmail').val(), password: $('#txtLogInPassword').val() }
});
});
});
</script>
</body>
</html>
有关异常的更多信息请参阅下面的堆栈跟踪。
[NullReferenceException: Object reference not set to an instance of an object.]
ASP._Page_Views_SignUpWizard_SignUpWizard_cshtml.Execute() in d:\Scheduler\Scheduler\Views\SignUpWizard\SignUpWizard.cshtml:2
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +96
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +257
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +294
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +23
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +21
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +175
System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +89
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +102
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +43
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +47
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9651688
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155