HttpWebRequest.IfModifiedSince プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > HttpWebRequest.IfModifiedSince プロパティの意味・解説 

HttpWebRequest.IfModifiedSince プロパティ

If-Modified-Since HTTP ヘッダーの値を取得または設定します

名前空間: System.Net
アセンブリ: System (system.dll 内)
構文構文

解説解説
使用例使用例

IfModifiedSince プロパティチェックするコード例次に示します

    ' Create a new 'Uri' object with the mentioned string.
    Dim myUri As New Uri("http://www.contoso.com")
    ' Create a new 'HttpWebRequest' object with the above 'Uri' object.
    Dim myHttpWebRequest As HttpWebRequest
 = CType(WebRequest.Create(myUri), HttpWebRequest)
    ' Create a new 'DateTime' object.
    Dim today As DateTime = DateTime.Now
    If DateTime.Compare(today, myHttpWebRequest.IfModifiedSince)
 = 0 Then
        ' Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse'
 variable.
        Dim myHttpWebResponse As HttpWebResponse
 = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
        Console.WriteLine("Response headers " + ControlChars.Cr
 + "{0}" + ControlChars.Cr, myHttpWebResponse.Headers)
        Dim streamResponse As Stream = myHttpWebResponse.GetResponseStream()
        Dim streamRead As New
 StreamReader(streamResponse)
        Dim readBuff(256) As [Char]
        Dim count As Integer
 = streamRead.Read(readBuff, 0, 256)
        Console.WriteLine(ControlChars.Cr + "The contents of Html
 Page are :  " + ControlChars.Cr)
        While count > 0
            Dim outputData As New
 [String](readBuff, 0, count)
            Console.Write(outputData)
            count = streamRead.Read(readBuff, 0, 256)
        End While
   ' Close the Stream object.
streamResponse.Close()
streamRead.Close()
   ' Release the HttpWebResponse Resource.
myHttpWebResponse.Close()
        Console.WriteLine(ControlChars.Cr + "Press 'Enter' key
 to continue.................")
        Console.Read()
    Else
        Console.WriteLine((ControlChars.Cr + "The page has been
 modified since " + today))
    End If
// Create a new 'Uri' object with the mentioned string.
Uri myUri =new Uri("http://www.contoso.com");
            
// Create a new 'HttpWebRequest' object with the above 'Uri' object.
HttpWebRequest myHttpWebRequest= (HttpWebRequest)WebRequest.Create(myUri);
// Create a new 'DateTime' object.
DateTime today= DateTime.Now;
if (DateTime.Compare(today,myHttpWebRequest.IfModifiedSince)==0)
{
    // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse'
 variable.
    HttpWebResponse myHttpWebResponse=(HttpWebResponse)myHttpWebRequest.GetResponse();
    Console.WriteLine("Response headers \n{0}\n",myHttpWebResponse.Headers);
    Stream streamResponse=myHttpWebResponse.GetResponseStream();
    StreamReader streamRead = new StreamReader( streamResponse
 );
    Char[] readBuff = new Char[256];
    int count = streamRead.Read( readBuff, 0, 256 );
    Console.WriteLine("\nThe contents of Html Page are :  \n");    
    while (count > 0) 
    {
        String outputData = new String(readBuff, 0, count);
        Console.Write(outputData);
        count = streamRead.Read(readBuff, 0, 256);
    }
    // Close the Stream object.
    streamResponse.Close();
    streamRead.Close();
    // Release the HttpWebResponse Resource.
    myHttpWebResponse.Close();
    Console.WriteLine("\nPress 'Enter' key to continue.................");
    
    Console.Read();
}
else
{
    Console.WriteLine("\nThe page has been modified since "+today);
}
      // Create a new 'Uri' object with the mentioned string.
      Uri^ myUri = gcnew Uri( "http://www.contoso.com" );
      
      // Create a new 'HttpWebRequest' object with the above 'Uri' object.
      HttpWebRequest^ myHttpWebRequest = dynamic_cast<HttpWebRequest^>(WebRequest::Create(
 myUri ));
      
      // Create a new 'DateTime' object.
      DateTime today = DateTime::Now;
      if ( DateTime::Compare( today, myHttpWebRequest->IfModifiedSince
 ) == 0 )
      {
         
         // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse'
 variable.
         HttpWebResponse^ myHttpWebResponse = dynamic_cast<HttpWebResponse^>(myHttpWebRequest->GetResponse());
         Console::WriteLine( "Response headers \n {0}\n", myHttpWebResponse->Headers
 );
         Stream^ streamResponse = myHttpWebResponse->GetResponseStream();
         StreamReader^ streamRead = gcnew StreamReader( streamResponse );
         array<Char>^readBuff = gcnew array<Char>(256);
         int count = streamRead->Read( readBuff, 0, 256 );
         Console::WriteLine( "\nThe contents of Html Page are :  \n" );
         while ( count > 0 )
         {
            String^ outputData = gcnew String( readBuff,0,count );
            Console::Write( outputData );
            count = streamRead->Read( readBuff, 0, 256 );
         }
         streamResponse->Close();
         streamRead->Close();
         
         // Release the HttpWebResponse Resource.
         myHttpWebResponse->Close();
         Console::WriteLine( "\nPress 'Enter' key to continue................."
 );
         Console::Read();
      }
      else
      {
         Console::WriteLine( "\nThe page has been modified since {0}",
 today );
      }
   }
   catch ( WebException^ e ) 
   {
      Console::WriteLine( "\nWebException Caught!" );
      Console::WriteLine( "Source  : {0}", e->Source );
      Console::WriteLine( "Message : {0}", e->Message );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "\nException raised!" );
      Console::WriteLine( "Source  : {0}", e->Source );
      Console::WriteLine( "Message : {0}", e->Message );
   }

}

// Create a new 'Uri' object with the mentioned string.
Uri myUri = new Uri("http://www.contoso.com");

//Create a new 'HttpWebRequest' object with the above 'Uri' object.
HttpWebRequest myHttpWebRequest = (HttpWebRequest)
    (WebRequest.Create(myUri));
// Create a new 'DateTime' object.
DateTime today = DateTime.get_Now();

if (DateTime.Compare(today, 
    myHttpWebRequest.get_IfModifiedSince()) == 0) {
    // Assign the response object of 'HttpWebRequest' to a 
    //    'HttpWebResponse' variable.
    HttpWebResponse myHttpWebResponse = (HttpWebResponse)
        (myHttpWebRequest.GetResponse());
    Console.WriteLine("Response headers \n{0}\n", 
        myHttpWebResponse.get_Headers());
    Stream streamResponse = myHttpWebResponse.GetResponseStream();
    StreamReader streamRead = new StreamReader(streamResponse);
    char readBuff[] = new char[256];
    int count = streamRead.Read(readBuff, 0, 256);
    Console.WriteLine("\nThe contents of Html Page are :  \n");
    while (count > 0) {
        String outputData = new String(readBuff, 0, count);
        Console.Write(outputData);
        count = streamRead.Read(readBuff, 0, 256);
    }
    // Close the Stream object.
    streamResponse.Close();
    streamRead.Close();
    // Release the HttpWebResponse Resource.
    myHttpWebResponse.Close();
    Console.WriteLine("\nPress 'Enter' key to continue"
        + ".................");
    Console.Read();
}
else {
    Console.WriteLine("\nThe page has been modified since "
        + today);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からHttpWebRequest.IfModifiedSince プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からHttpWebRequest.IfModifiedSince プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からHttpWebRequest.IfModifiedSince プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

HttpWebRequest.IfModifiedSince プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



HttpWebRequest.IfModifiedSince プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS