重定向如何在 ASP.Net MVC 中工作?
我从 Scott Henselman 的博客中复制并修改了代码位,该博客使用 DotNetOpenId 通过 OpenID 登录。调试,我发现在执行这段代码时:
// Stage 2: user submitting Identifier
var openId = Request.Form["openId"];
new OpenIdRelyingParty().CreateRequest(openId).RedirectToProvider();
throw new Exception("Should never get here");
我从来没有遇到过 throw 子句,而是继续重定向。这是如何运作的?
然后,当我从 OpenId 提供者那里得到响应时,我正在通过这个代码段进行调试:
switch (response.Status)
{
case AuthenticationStatus.Authenticated:
FormsAuthentication.RedirectFromLoginPage(response.ClaimedIdentifier, false);
// am I supposed to reach this line? What should I return here?
// (The method expects a View to be returned)
而且我发现对 FormsAuthentication.RedirectFromLoginPage() 的调用确实返回了,我需要从 Action 中返回一些东西。我应该在这里返回什么?