VS'12 asp.net MVC4를 사용 C# InternetApplication with KendoUI and Simplemembership EF Code.사용자 ID를 사용하여 등록 후 리디렉션
이것은 VS에서 시작하는 것입니다. 난 내 컨트롤러 ChangeUsersInfo
컨트롤러에 RedirectToAction
에 그것을 좋아하고 그것을 새로 만든 사용자의 ID를 전송 할 경우 다음
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Register(RegisterModel model)
{
if (ModelState.IsValid)
{
// Attempt to register the user
try
{
WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
WebSecurity.Login(model.UserName, model.Password);
return RedirectToAction("Index", "Home");
.
.
.
이다.
내가
1.
var UserID = (from u in db.UserProfiles
where u.UserName == User.Identity.Name
select new
{
UserID = u.UserID
}).Single();
2.
var userID = System.Web.Security.Membership.GetUser().ProviderUserKey;
리턴 RedirectToAction 시도 ID를 얻으려면 ("편집", "ChangeUsersInfo"사용자 ID);
또한 변수없이 보낼 수 있는지 알기 위해
return RedirectToAction("Edit","ChangeUsersInfo");
을 사용해 보았습니다.- 변수 반환 = 널
- 변수 = 반환 몇 가지 이유를 들어
- 나던 작업
- 보인다 1 개, 2 didnt 한 새로운
EDIT
에 있지만 리디렉션되지하기 때문에LOG IN
화면
null 값의 원인과 리디렉션이 실패한 이유는 무엇입니까?
예 데이터베이스가 WebSecurity를 사용하여 사용자
'리턴 RedirectToAction ("인덱스", "채널 angeUsersInfo ");'는 여전히 내 액션/컨트롤러로 나를 리다이렉트시키지 않을 것이고, 그것은 나의 브레이크 포인트를 타격하지 않을 것이다. 또한 쿠키 및 Websecurity 정보를 제공해 주셔서 감사합니다. –
또한 새로운 로그인 사용자를 로그인하지만 로그인 화면에 남겨 둡니다. (0 리다이렉트 - 다른 사람은 내 것입니다) –
당신의 방법은 효과적이었습니다. 편집 섹션. 그 일은 지금 너무나 감사합니다! –