成功登录后如何重定向到页面?

时间:2022-04-12 06:36:16

I'm fairly new to web forms development, playing around with a project created using the ASP.NET Web Application template in VS 2010. After the user successfully logs in, I want the user redirected to a page I created. How do I modify my project to redirect the user after login? Any samples / tutorials / etc are greatly appreciated.

我是Web表单开发的新手,在VS 2010中使用ASP.NET Web应用程序模板创建的项目。在用户成功登录后,我希望用户重定向到我创建的页面。如何在登录后修改我的项目以重定向用户?任何样本/教程/等都非常感谢。

Thanks!

6 个解决方案

#1


11  

To simply redirect to a new page when your user has logged in, use the DestinationPageUrl property of your login control... assuming you're using the Login control that is.

要在用户登录时简单地重定向到新页面,请使用登录控件的DestinationPageUrl属性...假设您使用的是Login控件。

If you need to do anything more advanced you can use the OnLoggedIn event handler for your Login control to perform a redirect manually, or add any code for event logging and such.

如果您需要执行更高级的操作,可以使用Login控件的OnLoggedIn事件处理程序手动执行重定向,或者为事件日志记录添加任何代码等。

If you've rolled your own login control, and are just using things like text boxes and button controls, then in your Button_Click event, you can just use Response.Redirect("DestinationHere"); to take your users to a new page.

如果您已经推出了自己的登录控件,并且只是使用文本框和按钮控件之类的东西,那么在Button_Click事件中,您只需使用Response.Redirect(“DestinationHere”);将您的用户带到新页面。

#2


4  

After you checked for login:

检查登录后:

Response.Redirect("url");

#3


1  

I assume you're using ASP.NET Login control. There's a DestinationPageUrl property of that control that handles exactly that. If login was successfull user is redirected to URL provided in that property.

我假设您正在使用ASP.NET登录控件。该控件的DestinationPageUrl属性可以完全处理该属性。如果登录成功,则用户将被重定向到该属性中提供的URL。

#4


1  

  <asp:Login ID="Login1" runat="server" DestinationPageUrl="~/Admin/Default.aspx">
</asp:Login>

Go to Properties and Set DestinationPageUrl.

转到属性并设置DestinationPageUrl。

#5


0  

Server.Transfer( *url*) ?

(method on HttpServerUtility)

(关于HttpServerUtility的方法)

I know next to nothing about ASP.NET, but from my Java web developer daze, redirect is bad because it involves another network round trip to the browser and back when you really just want to continue processing in another page.

我对ASP.NET几乎一无所知,但是从我的Java Web开发人员发呆,重定向很糟糕,因为它涉及到浏览器的另一个网络往返,当你真的只想继续在另一个页面处理时。

And Response.Redirect() really does issue a 302 response code ("try this other url instead") back to the browser. yuck. XP

并且Response.Redirect()确实会向浏览器发出302响应代码(“尝试使用其他网址”)。呸。 XP

Server.Transfer() looks like the java version of Response.Forward()

Server.Transfer()看起来像Response.Forward()的java版本

#6


0  

For Sharepoint farm solution development

对于Sharepoint场解决方案开发

Page.Response.Redirect("url");

#1


11  

To simply redirect to a new page when your user has logged in, use the DestinationPageUrl property of your login control... assuming you're using the Login control that is.

要在用户登录时简单地重定向到新页面,请使用登录控件的DestinationPageUrl属性...假设您使用的是Login控件。

If you need to do anything more advanced you can use the OnLoggedIn event handler for your Login control to perform a redirect manually, or add any code for event logging and such.

如果您需要执行更高级的操作,可以使用Login控件的OnLoggedIn事件处理程序手动执行重定向,或者为事件日志记录添加任何代码等。

If you've rolled your own login control, and are just using things like text boxes and button controls, then in your Button_Click event, you can just use Response.Redirect("DestinationHere"); to take your users to a new page.

如果您已经推出了自己的登录控件,并且只是使用文本框和按钮控件之类的东西,那么在Button_Click事件中,您只需使用Response.Redirect(“DestinationHere”);将您的用户带到新页面。

#2


4  

After you checked for login:

检查登录后:

Response.Redirect("url");

#3


1  

I assume you're using ASP.NET Login control. There's a DestinationPageUrl property of that control that handles exactly that. If login was successfull user is redirected to URL provided in that property.

我假设您正在使用ASP.NET登录控件。该控件的DestinationPageUrl属性可以完全处理该属性。如果登录成功,则用户将被重定向到该属性中提供的URL。

#4


1  

  <asp:Login ID="Login1" runat="server" DestinationPageUrl="~/Admin/Default.aspx">
</asp:Login>

Go to Properties and Set DestinationPageUrl.

转到属性并设置DestinationPageUrl。

#5


0  

Server.Transfer( *url*) ?

(method on HttpServerUtility)

(关于HttpServerUtility的方法)

I know next to nothing about ASP.NET, but from my Java web developer daze, redirect is bad because it involves another network round trip to the browser and back when you really just want to continue processing in another page.

我对ASP.NET几乎一无所知,但是从我的Java Web开发人员发呆,重定向很糟糕,因为它涉及到浏览器的另一个网络往返,当你真的只想继续在另一个页面处理时。

And Response.Redirect() really does issue a 302 response code ("try this other url instead") back to the browser. yuck. XP

并且Response.Redirect()确实会向浏览器发出302响应代码(“尝试使用其他网址”)。呸。 XP

Server.Transfer() looks like the java version of Response.Forward()

Server.Transfer()看起来像Response.Forward()的java版本

#6


0  

For Sharepoint farm solution development

对于Sharepoint场解决方案开发

Page.Response.Redirect("url");