简体   繁体   English

如何使用ASP.NET重定向到另一个页面?

[英]How do I redirect to another page with ASP.NET?

I know it's a simple question but I really can't find anything on Google. 我知道这是一个简单的问题但我在Google上找不到任何东西。 Sorry if I'm not searching right. 对不起,如果我没有正确搜索。 I created 2 pages and in the first one I have a button. 我创建了2页,在第一页中我有一个按钮。
What should I write in the C# code to change to redirect me on the second page? 我应该在C#代码中写什么来改变以在第二页上重定向我?
I usually know my way around C# but I'm totally new in ASP. 我通常知道我在C#的方式,但我是ASP的新手。

Not quite sure from your question whether you're after ASP VB or C#...so... 从你的问题不太确定你是在使用ASP VB还是C#...所以......

// C# // C#

private void Button1_Click(object sender, System.EventArgs e)
{
   Server.Transfer("Webform2.aspx");
}

' Visual Basic 'Visual Basic

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Server.Transfer("Webform2.aspx")
End Sub

For more information, I direct you to: 有关更多信息,请指导您:

http://msdn.microsoft.com/en-us/library/540y83hx%28VS.71%29.aspx http://msdn.microsoft.com/en-us/library/540y83hx%28VS.71%29.aspx

您也可以使用按钮的PostBackUrl属性在aspx本身(不编写任何代码)中执行此操作。

Use one of these methods: 使用以下方法之一:

One-time redirect (HTTP 301) 一次性重定向(HTTP 301)

Response.Redirect("page to redirect to");

Permanent redirect (HTTP 302), only available in ASP.NET 4.0 永久重定向(HTTP 302),仅在ASP.NET 4.0中可用

Response.RedirectPermanent("page to redirect to");

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

相关问题 如何使用 Z686155AF75A60A0EDD3F6E9D80C1 从 ASP.NET Controller 重定向到另一个 web 页面? - How do I redirect to another web page from an ASP.NET Controller using JavaScript? 如何在ASP.NET中从RadPane重定向到另一个页面? - How do I redirect to another page from RadPane in ASP.NET? 如何在asp.net的另一个解决方案中重定向到另一个页面? - How to Redirect to another Page in another solution in asp.net? 如何从一个ASP.NET页面重定向到另一个 - How to redirect from one ASP.NET page to another 如何在ASP.NET中进行请求期间重定向到另一个页面 - How to redirect to another page during request in ASP.NET 如何重定向到多个页面在asp.net中导致 - How to redirect to another page with muiltple results in asp.net 如何重定向到btnclick调用的函数中的另一个页面。 ASP.NET - how can i redirect to another page in function that called by btnclick. ASP.NET 如何在ASP.NET 5中提供静态页面并将用户重定向到该页面? - How do I serve a static page in ASP.NET 5 and redirect users to it? 如何从Silverlight应用程序内重定向包含Silverlight应用程序的asp.net页面? - How do I redirect the asp.net page that contains a silverlight app from within the silverlight app? 如何在页面重定向后发布消息以确认已发送的消息(C#/ ASP.Net) - How do I post a message to confirm a sent message after a page redirect (C#/ASP.Net)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM