Vấn đề là e có 2 file
a.php
echo 'Text A'; header('location: b.php');
b.php
echo 'Text B';
vấn đề là e muốn lấy html và link b.php từ file a.php (mục đích là để nếu có xuất hiện chuyển hướng thì load xong file a.php sẽ load tiếp file b.php)
- nếu e dùng
request.AllowAutoRedirect = false;để chặn chuyển hướng thì chỉ lấy được html, ko lấy được link chuyển hướng - nếu e dùng
request.AllowAutoRedirect = truethì bắt được link chuyển hướng, ko lấy được html ??
Có ai hiểu vấn đề e đang trình bày ko ạ ? Bác nào có cách giải quyết giúp e với. Tks
Code đầy đủ:
using System;
using System.Net;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("a.php");
request.Method = "GET";
request.AllowAutoRedirect = false;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string html = new StreamReader(response.GetResponseStream()).ReadToEnd();
Console.WriteLine(response.ResponseUri + "\n" + html);
}
catch(WebException e)
{
Console.WriteLine(e.Status);
}
Console.ReadKey();
}
}
}

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?