IronPDF'de Kerberos'u Anlama

This article was translated from English: Does it need improvement?
Translated
View the article in English

UrlToPdf'i Kerberos kimlik doğrulaması ile çalıştırmayı nasıl sağlayabilirim?

IronPDF'in UrlToPdf ile Kerberos kimlik doğrulamasını kullanmak için, render ayarlarına bir kullanıcı adı ve şifre belirlemelisiniz. Daha fazla ayrıntı için IronPDF belgelerine başvurabilirsiniz: IronPdf.ChromeHttpLoginCredentials.

HTML içeriğini indirmek için System.Net.Http.HttpClient kullanmanızı öneririz, bu içerik daha sonra renderlanabilir. Bu yaklaşım, IronPDF içeriği işlemeden önce kimlik doğrulaması gerektirenler dahil HTTP isteklerini yönetmenizi sağlar.

Kerberos ile sayfa indirme hakkında çevrimiçi bir kılavuz: System.Net.Http.HttpClient kimlik doğrulama türünü nasıl seçiyor?. Bu StackOverflow bağlantısı, HttpClient kullanarak kimlik doğrulama uygulaması hakkında ayrıntılı bir tartışma sunmaktadır.

HTML içindeki tüm gerekli varlıkların indirildiğinden emin olmak ve süreçleri analiz etmek için HTML Agility Pack'i kullanmayı düşünün. Bu .NET kütüphanesi, HTML belgelerini etkili bir şekilde sorgulama ve manipülasyon yapmada yardımcı olur.

// Example: Using HttpClient with Kerberos Authentication

// Import the necessary namespaces
using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

namespace KerberosAuthenticationExample
{
    class Program
    {
        static async Task Main(string[] args)
        {
            // Create an instance of HttpClient
            HttpClientHandler handler = new HttpClientHandler
            {
                // Automatically use default network credentials
                UseDefaultCredentials = true // Enables Windows authentication (e.g., Kerberos)
            };

            using HttpClient httpClient = new HttpClient(handler);

            try
            {
                // Send a GET request to the desired URL
                HttpResponseMessage response = await httpClient.GetAsync("https://your-secure-url.com");

                // Ensure the request was successful
                response.EnsureSuccessStatusCode();

                // Read and display the response body
                string responseBody = await response.Content.ReadAsStringAsync();
                Console.WriteLine(responseBody);

                // If needed, render the HTML to PDF with IronPDF here
                // IronPdf.HtmlToPdf renderer = new IronPdf.HtmlToPdf();
                // renderer.RenderHtmlAsPdf(responseBody).SaveAs("output.pdf");
            }
            catch (HttpRequestException e)
            {
                // Handle any error responses from the server or connection issues
                Console.WriteLine("\nException Caught!");
                Console.WriteLine($"Message :{e.Message}");
            }
        }
    }
}
// Example: Using HttpClient with Kerberos Authentication

// Import the necessary namespaces
using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

namespace KerberosAuthenticationExample
{
    class Program
    {
        static async Task Main(string[] args)
        {
            // Create an instance of HttpClient
            HttpClientHandler handler = new HttpClientHandler
            {
                // Automatically use default network credentials
                UseDefaultCredentials = true // Enables Windows authentication (e.g., Kerberos)
            };

            using HttpClient httpClient = new HttpClient(handler);

            try
            {
                // Send a GET request to the desired URL
                HttpResponseMessage response = await httpClient.GetAsync("https://your-secure-url.com");

                // Ensure the request was successful
                response.EnsureSuccessStatusCode();

                // Read and display the response body
                string responseBody = await response.Content.ReadAsStringAsync();
                Console.WriteLine(responseBody);

                // If needed, render the HTML to PDF with IronPDF here
                // IronPdf.HtmlToPdf renderer = new IronPdf.HtmlToPdf();
                // renderer.RenderHtmlAsPdf(responseBody).SaveAs("output.pdf");
            }
            catch (HttpRequestException e)
            {
                // Handle any error responses from the server or connection issues
                Console.WriteLine("\nException Caught!");
                Console.WriteLine($"Message :{e.Message}");
            }
        }
    }
}
' Example: Using HttpClient with Kerberos Authentication

' Import the necessary namespaces
Imports Microsoft.VisualBasic
Imports System
Imports System.Net
Imports System.Net.Http
Imports System.Net.Http.Headers
Imports System.Threading.Tasks

Namespace KerberosAuthenticationExample
	Friend Class Program
		Shared Async Function Main(ByVal args() As String) As Task
			' Create an instance of HttpClient
			Dim handler As New HttpClientHandler With {.UseDefaultCredentials = True}

			Using httpClient As New HttpClient(handler)
	
				Try
					' Send a GET request to the desired URL
					Dim response As HttpResponseMessage = Await httpClient.GetAsync("https://your-secure-url.com")
	
					' Ensure the request was successful
					response.EnsureSuccessStatusCode()
	
					' Read and display the response body
					Dim responseBody As String = Await response.Content.ReadAsStringAsync()
					Console.WriteLine(responseBody)
	
					' If needed, render the HTML to PDF with IronPDF here
					' IronPdf.HtmlToPdf renderer = new IronPdf.HtmlToPdf();
					' renderer.RenderHtmlAsPdf(responseBody).SaveAs("output.pdf");
				Catch e As HttpRequestException
					' Handle any error responses from the server or connection issues
					Console.WriteLine(vbLf & "Exception Caught!")
					Console.WriteLine($"Message :{e.Message}")
				End Try
			End Using
		End Function
	End Class
End Namespace
$vbLabelText   $csharpLabel

Anahtar noktalar:

  • HttpClient ve HttpClientHandler: Kerberos kimlik doğrulamasına mevcut kullanıcının kimlik bilgileriyle izin vermek için HttpClientHandler ile UseDefaultCredentials = true kullanın.
  • Hata Yönetimi: HTTP istekleri sırasında istisnaları yönetmek için try-catch blokları uygulayın.
  • HTML Oluşturma: HTML alındıktan sonra gerekirse içeriği PDF'e dönüştürmek için IronPDF'i kullanın.
Curtis Chau
Teknik Yazar

Curtis Chau, Bilgisayar Bilimleri alanında lisans derecesine sahiptir (Carleton Üniversitesi) ve Node.js, TypeScript, JavaScript ve React konularında uzmanlaşmış ön uç geliştirme üzerine uzmanlaşmıştır. Kullanıcı dostu ve estetik açıdan hoş arayüzler tasarlamaya tutkuyla bağlı olan Curtis, modern çerç...

Daha Fazlasını Oku
Başlamaya Hazır mısınız?
Nuget Indirmeler 18,332,619 | Sürüm: 2026.4 yeni yayınlandı
Still Scrolling Icon

Hala Kaydiriyor musunuz?

Hızlı bir kanit mi istiyorsunuz? PM > Install-Package IronPdf
bir örnek çalıştır HTML'nizin PDF olduğunu izleyin.