Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7f1da5e

Browse files
returnurl in asp.net core
1 parent 685047f commit 7f1da5e

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

‎Webgentle.BookStore/Webgentle.BookStore/Controllers/AccountController.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,17 @@ public IActionResult Login()
5757

5858
[Route("login")]
5959
[HttpPost]
60-
public async Task<IActionResult> Login(SignInModel signInModel)
60+
public async Task<IActionResult> Login(SignInModel signInModel,stringreturnUrl)
6161
{
6262
if (ModelState.IsValid)
6363
{
6464
var result = await _accountRepository.PasswordSignInAsync(signInModel);
6565
if (result.Succeeded)
6666
{
67+
if (!string.IsNullOrEmpty(returnUrl))
68+
{
69+
return LocalRedirect(returnUrl);
70+
}
6771
return RedirectToAction("Index", "Home");
6872
}
6973

‎Webgentle.BookStore/Webgentle.BookStore/Views/Account/Login.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<div class="container">
3434
<div class="row">
3535
<div class="col-md-4">
36-
<form asp-action="Login">
36+
<form method="post">
3737
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
3838
<div class="form-group">
3939
<label asp-for="Email" class="control-label"></label>

‎Webgentle.BookStore/Webgentle.BookStore/Views/Shared/_LoginInfo.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
else
1616
{
1717
<li class="nav-item">
18-
<a class="btn btn-outline-primary" asp-controller="Account" asp-action="Login">Login</a>
18+
<a class="btn btn-outline-primary" asp-controller="Account" asp-action="Login"asp-route-returnUrl="@Context.Request.Path">Login</a>
1919
<a class="btn btn-primary" asp-controller="Account" asp-action="Signup">Register</a>
2020
</li>
2121
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /