如何知道计算机用户使用浏览器在c#中使用http或https访问网站? [英] How to know that computer user use browser to visit websites by using http or https in c#?

查看:80
本文介绍了如何知道计算机用户使用浏览器在c#中使用http或https访问网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在做Windows应用程序并尝试在计算机用户使用http / https从互联网请求任何信息时获取信息。我试图通过计算机用户从http或https(对于任何类型的浏览器)获取请求的URL信息

Hi all,

I am doing windows application and trying to get information whenever computer user use http / https to request any information from internet. I am trying to get information requested url by computer user from http or https (for any type of browser)

推荐答案

您可以通过检查网址方案,使用Request.Url.Scheme。



You can do it by checking the url scheme, using the Request.Url.Scheme.

public void Init(HttpApplication application)
{
    application.BeginRequest += new EventHandler(application_BeginRequest);
}

protected void application_BeginRequest(object sender, EventArgs e)
{
    HttpApplication application = ((HttpApplication)(sender));
    HttpRequest request = application.Request;

    if (request.Url.Schema == "http://" || "https://")
    {
         Response.Redirect(request.Url);
    }

}


这篇关于如何知道计算机用户使用浏览器在c#中使用http或https访问网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆