众所周知,web开发中跳转无处不在,jsp中的跳转有客户端的跳转和服务器端的跳转。asp.net也不例外,但是asp.net的更为丰富,主要是下面几种
Server.Transfer()方法
Server.Execute()方法
表单页面就不贴出来了,下面看下一般处理程序
using System;
using System.Collections;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
namespace redirect.servlet
{
/// <summary>
/// $codebehindclassname$ 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Handler1 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/html";
//取得用户名和密码
string password = context.Request["password"];
string name = context.Request["name"];
if (password.Equals("123456") && name.Equals("tom"))
{
context.Server.Transfer("/manage/success.aspx");
}
else {
context.Response.Redirect("/manage/failure.aspx");
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
做的过程中,个人总结了一下,如果要跳转到aspx页面,最好不要使用redirect,html这种静态页面就随便使用哪种都可以。
3847



被折叠的 条评论
为什么被折叠?



