0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ASP.NETブラウザの判定方法

Posted at

HTTPリクエストに含まれるBrowserオブジェクトを利用する

public HttpBrowserCapabilities Browser { get; set; }
  • 利用例
LogActionFilter.cs
public override void OnResultExecuted(ResultExecutedContext filterContext)
{
    var request = filterContext.HttpContext.Request;
    Encoding sjisEnc = Encoding.GetEncoding("Shift_JIS");
    StreamWriter writer = new StreamWriter(@"D:\WebSites\TEST1126\Log\Log.txt", true, sjisEnc);
    writer.WriteLine("テスト書き込みです。[{0}]", request.Browser.Browser);
    writer.Close();
}
  • 結果
テスト書き込みです。[InternetExplorer]
テスト書き込みです。[Chrome]
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?