我正在使用 owin自定义身份验证和 asp.net身份,并拥有如下登录网址:
http://localhost:1927/
登录后,用户将被重定向到仪表板页面,网址将如下所示:
http://localhost:1927/Dashboard/Index
现在用户注销后我将用户重定向到登录页面,网址仍然很好,如下所示:
但现在当我直接在浏览器中输入此网址http://localhost:1927/Dashboard/Index
时,我又会重定向到登录状态
页面和网址更改为以下网址:
http://localhost:1927/Authentication/Login?ReturnUrl=%2FDashboard%2FIndex
我知道这是因为我已将Authentication and Dashboard controller
与Authorize attribute
装饰在一起。
代码:
[Authorize]
public class AuthenticationController : Controller
{
}
[Authorize]
public class DashboardController : Controller
{
}
public partial class Startup
{
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
public void ConfigureAuth(IAppBuilder app)
{
// Enable the application to use a cookie to store information for the signed in user
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Authentication/Login")
});
// Use a cookie to temporarily store information about a user logging in with a third party login provider
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
}
}
的Web.config:
<authentication mode="None" />
<modules>
<remove name="FormsAuthenticationModule" />
</modules>
因此可以在重定向到登录页面时使用如下所示的URL:
http://localhost:1927/
如果是,那么如何?