【发布时间】:2010-01-02 14:20:36
【问题描述】:
重定向在 ASP.Net MVC 中如何工作?
我已经复制并修改了使用 DotNetOpenId 通过 OpenID 登录的code bit from Scott Henselman's blog。调试,我发现在执行这段代码的时候:
// 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 中返回一些内容。我应该在这里返回什么?
【问题讨论】:
标签: asp.net-mvc redirect dotnetopenauth