登陆 | 注册
你现在的位置:我的论坛 >> 微软新技术 >> Response.AppendHeader 使用
Response.AppendHeader 使用
大狗熊

文件下载,指定默认名srxljl
Response.AddHeader("content-type","application/x-msdownload");
Response.AddHeader("Content-Disposition","attachment;filename=要下载的文件名.rar");

刷新页面
srxljl
Response.AddHeader “REFRESH”, ”60;URL=newpath/newpage.asp”
这等同于客户机端<META>元素:
<META HTTP-EQUIV=”REFRESH”, “60;URL=newpath/newpage.asp”

页面转向srxljl
Response.Status = “302 Object Moved”
Response.Addheader “Location”, “newpath/newpage.asp”
这等同于使用Response.Redirect方法:
Response.Redirect “newpath/newpage.asp”

强制浏览器显示一个用户名/口令对话框srxljl
Response.Status= “401 Unauthorized”
Response.Addheader “WWW-Authenticate”, “BASIC”
强制浏览器显示一个用户名/口令对话框,然后使用BASIC验证把它们发送回服务器(将在本书后续部分看到验证方法)。

如何让网页不缓冲
srxljl
Response.Expires = 0
Response.ExpiresAbsolute = Now() - 1
Response.Addheader "pragma","no-cache"
Response.Addheader "cache-control","private"
Response.CacheControl = "no-cache

楼主 创建:08-08-28 16:05:37 更新:08-08-28 16:05:37
发表回复

1/1(共1页)
大狗熊 using System;
using System.IO;
using System.Web.UI;
using System.Web.Security;

using Dang.Util;

namespace Dang.Home.Web
{
    
public class snap_shot : Page
    {
        
protected void Page_Load(object sender, EventArgs e)
        {
            
string auth = null;
            
string[] up = null;
            
if (
                (auth 
= Request.Headers["Authorization"]) != null
                
&& auth.Length > 6
                
&& (up = EConvert.FromBase64(auth.Substring(6)).Split(':')).Length > 1
                
&& FormsAuthentication.Authenticate(up[0], up[1])
               )
                
return;

            Response.AppendHeader(
"WWW-Authenticate""Basic realm=enter your username and password");
            Response.StatusCode 
= 401;
            Response.Write(
"Access Dined");
            Response.End();

        }

        
protected void btnOK_Click(object sender, EventArgs e)
        {
            StringWriter writer 
= new StringWriter();
            Server.Execute(
"default.aspx", writer);
            
string html = writer.ToString();
            writer.Close();
            Response.Write(WebHelper.Write(
"index.html", html) ? "写入成功" : "写入失败");
        }
    }
}
1楼 创建:08-09-23 19:54:29 更新:08-09-23 19:54:29
发表回复
1 共1条
Copyright (C) 2004-2008, All Rights Reserved