我有编码,但是我不知道它是如何工作的.我需要帮助 [英] I Have Coding But I Don't Know How It Working. I Need Help Plz
问题描述
我在下面列出的编码.此编码如何工作.此编码在Microsoft Visual Studio 2010中可用.
他们以登录形式使用
The coding that i listed below . How this coding working. This coding is availble in microsoft visual studio 2010.
In login form they use
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
RegisterHyperLink.NavigateUrl = "Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString("ReturnUrl"))
End Sub
他们以注册表形式使用
In register form they use
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
RegisterUser.ContinueDestinationPageUrl = Request.QueryString("ReturnUrl")
End Sub
Protected Sub RegisterUser_CreatedUser(ByVal sender As Object, ByVal e As EventArgs) Handles RegisterUser.CreatedUser
FormsAuthentication.SetAuthCookie(RegisterUser.UserName, False)
Dim continueUrl As String = RegisterUser.ContinueDestinationPageUrl
If String.IsNullOrEmpty(continueUrl) Then
continueUrl = "~/"
End If
Response.Redirect(continueUrl)
End Sub
推荐答案
查看导航网址:
Look at the navigate URL:
RegisterHyperLink.NavigateUrl = "Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString("ReturnUrl"))
这样做是在设置一个Register链接,以便它记住"链接从中单击的位置:ReturnUrl.
当用户尝试转到"mysite.com/page1.aspx"并且未登录时,系统会将它们重定向到"mysite.com/login.aspx?ReturnUrl=mysite",以将其发送到登录页面. com/page1.aspx",以便他们登录后可以读取地址并提取"ReturnUrl"的查询字符串,并获得他们开始的页面.
您所有代码所做的就是将其传递给Register.apsx页面,以便在那里完成操作后可以返回到原来的页面.
查询字符串是一种实现方法-它们倾向于显示在地址栏中,所以这不是我的偏好-而是?"之后的任何内容基本上是您的页面可以访问的键值对数据.您可以在此处阅读有关它们的信息: http://en.wikipedia.org/wiki/Query_string [
What that is doing is setting a Register link so it "remembers" where the link was clicked from: the ReturnUrl.
When you user tried to go to "mysite.com/page1.aspx" and they aren''t logged in, the system send them to the login page by redirecting them to "mysite.com/login.aspx?ReturnUrl=mysite.com/page1.aspx" so that when they have logged in it can read the address and extract the query string for "ReturnUrl" and get the page they started on.
All your code is doing is passing that on to the Register.apsx page so that when they are finished there it can do the same thing and return to the page they originally came from.
Query strings are one way to do it - they tend to show in the address bar, so it''s not my preference - but anything after the "?" is basically key-value pair data your page can access. You can read about them here: http://en.wikipedia.org/wiki/Query_string[^]
Personally, I''d use the Session, as it''s invisible to the user.
这篇关于我有编码,但是我不知道它是如何工作的.我需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!