我是从实现 软件下载功能  地址显示为down.aspx?id=1,在转到软件的具体下载地址.部分程序如下:
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
addHits();
getmusic();
Response.BufferOutput=true;

                           Response.Redirect("url");

}
private void addHits()
{
SqlConnection1 = new SqlConnection(ConfigurationSettings.AppSettings["dsn"]); //取连接字符串,并建立连接
SqlCommand1=new SqlCommand("sp_musichits",SqlConnection1); 
SqlCommand1.CommandType=CommandType.StoredProcedure;
SqlCommand1.Parameters.Add(new SqlParameter("@id",SqlDbType.BigInt));
SqlCommand1.Parameters["@id"].Value = Request["id"];
try
{
SqlConnection1.Open();
int i=SqlCommand1.ExecuteNonQuery();
}
catch (SqlException e1)
{

}
SqlConnection1.Close();
}
private void getmusic()  //取得歌曲地址
{
SqlConnection1 = new SqlConnection(ConfigurationSettings.AppSettings["dsn"]);//取连接字符串,并建立连接
SqlCommand1=new SqlCommand("sp_musicplay",SqlConnection1); 
SqlCommand1.CommandType=CommandType.StoredProcedure;
SqlCommand1.Parameters.Add(new SqlParameter("@id",SqlDbType.BigInt));
SqlCommand1.Parameters["@id"].Value = Request["id"];
ds= new DataSet();

try
{
SqlConnection1.Open();
SqlDataReader1=SqlCommand1.ExecuteReader();
}
catch (SqlException e1)
{
Label1.Text ="数据库操作错误:"+e1.Message;
}
if(SqlDataReader1.Read()==true)   //如果改变了用户名,就要检查是否与已有的记录相同
{
id=SqlDataReader1.GetInt64(0);
url=SqlDataReader1.GetString(3);

}

SqlConnection1.Close();

}为什么他实现不了,转到具体下载页. 而是显示为http://localhost/myweb/url,谢谢.

解决方案 »

  1.   

    Response.Redirect("url");!!!!
    你这句怎么行呢,如果是地址存在url这个变量中应该是这样吧。
    Response.Redirect(url);
      

  2.   

    to  dutguoyi(新鲜鱼排) :(Response.Redirect(url);)  url一定要引号的.
    to  zxkid(没有人会像我这样...) :yoServer.Transfer(url);运行后显示,子请求“http://0o2.net/My/music/mp3/45.wma ”的路径无效。应为虚拟路径。 我的url为网址,不行呀.谢谢.帮我在看看.
      

  3.   

    首先同意 hjf1223(学点有技术含量的!) 的说法。把你的地址放到变量url中后,调用Response.Redirect(url);
    重定向。但是还有个问题需要注意的是,你的url如果不是同一个项目中,需要写包含["http://"]为开头的地址,否则如你的错误显示:显示为http://localhost/myweb/url了
      

  4.   

    to ; yqz(最后一个馒头) ( ) ,用Response.Redirect(url);试了,他说找不到网页,地址栏显示为http://localhost/myweb/mp3.aspx?id=3,为什么.谢谢