简体   繁体   English

登录后将用户重定向到特定页面

[英]Redirect user to a specific page after login

In web application, after login "ReturnUrl" going to last visited page. 在Web应用程序中,登录“ ReturnUrl”后将转到上次访问的页面。 How to set to go default.aspx. 如何设置为default.aspx。

I declared code in web.config like this. 我像这样在web.config中声明了代码。

      <forms name="FormsAuth" loginUrl="Default.aspx" defaultUrl="Default.aspx" 
path="/" timeout="200" slidingExpiration="true">

But If I close application at /Private/Admin/ReviewIssue.aspx page. 但是,如果我在/Private/Admin/ReviewIssue.aspx页面上关闭应用程序。

When I start again application in login page url has like this 当我再次启动登录页面网址中的应用程序时,就像这样

    http://localhost:3042/Test/Default.aspx?ReturnUrl=
%2fPrivate%2fAdmin%2fReviewIssue.aspx

I want from login page to Default.aspx only. 我只想从登录页面到Default.aspx。

Assuming this is for an ASP.NET web forms project created from the Visual Studio template, go to Register.aspx.cs in the Account folder and edit the code there to be 假定这是从Visual Studio模板创建的ASP.NET Web窗体项目,请转到Account文件夹中的Register.aspx.cs并在其中编辑代码

    protected void RegisterUser_CreatedUser(object sender, EventArgs e)
    {
        FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);

        Response.Redirect( "~/default.aspx" );
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM