易截截图软件、单文件、免安装、纯绿色、仅160KB

ASP.net页面跳转方式三种

 
asp.net在开发时,在不同的页面间跳转是我们常遇到的一件事,当一个复杂的逻辑在一个页面放不下分成二个或多个页面处理就需要在页面间跳转,用的最多还是用户的登陆吧.
ASP.NET用的最多的跳转是Response.Redirect,这个命令可以直接把请求重定向到一个相对或绝对的路径.它会把当前页面的的Http流阻断直接重定向到新的URL.
而Server.Transfer,这个命令是由IIS服务器直接在服务器端执行跳转,这个跳转的路径必须是相对路径,也就是同一个网站下面的PATH或虚拟目眼录.不能是外网的绝对路径,因为直接是由当前请求页面的同一个HTTP句柄指定请求同一站点上的路径.
它们的区别在哪,先看下HTTP 头吧,先看Response.Redirect
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Redirect("/redirect.aspx"); //直接重定向到本站的其路径上
        }
http://xml.test.com/HttpStatus.aspx -->这个是指我请求执行的页面
GET /HttpStatus.aspx HTTP/1.1
Host: xml.test.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn,zh;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: gb2312,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
HTTP/1.x 302 Found -->注意这个302
Cache-Control: private
Content-Type: text/html; charset=utf-8
Location: /redirect.aspx
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Sun, 01 Nov 2009 12:12:45 GMT
Content-Length: 133
----------------------------------------------------------
http://xml.test.com/redirect.aspx-->  这个是请求跳转的页面
GET /redirect.aspx HTTP/1.1
Host: xml.test.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn,zh;q


相关文档:

asp.net中自动附加数据库的代码


直接把数据库放置App_data文件夹中,添加一个web.config配置文件然后写如下代码
<connectionStrings>
    <add name="users" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|Users.mdf;Integrated Security=True;User Instance=True" providerName="System.Data ......

asp.net清除html标记

#region 清除文本样式  主要应用于从网络粘贴进来的文本
        [WebMethod]
        public static string ClearStyle(string yourStr)//清除样式
        {
      & ......

ASP.NET 页面事件执行顺序 收藏

ASP.NET 页面事件执行顺序 收藏
过程描述
下面是ASP.NET页面初始的过程:
1. Page_Init();
2. Load ViewState;
3. Load Postback data;
4. Page_Load();
5. Handle control events;
6. Page_PreRender();
7. Page_Render();
8. Unload event;
9. Dispose method called;
下面对其中的一些过程作下描述:
1. Pa ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号